Skip to content

Instantly share code, notes, and snippets.

@GrHalbgott
Last active August 22, 2022 15:30
Show Gist options
  • Save GrHalbgott/0ab06e5f200f59995860984ebd4999a8 to your computer and use it in GitHub Desktop.
Save GrHalbgott/0ab06e5f200f59995860984ebd4999a8 to your computer and use it in GitHub Desktop.
Git-Bash cheat sheet

Git-Bash cheat sheet

The standard commands to use git in a local folder and to keep a current version online in GitHub (synchronisation).

Command Description
Go into the desired folder - right-click "Git-Bash here"` This way you don't have to cd into the folder. If you have cloned your repository, you are ready to go. If not, you don't need to specify a target location of the folder to be cloned.
git clone RepoURL (insert desired name (with path) or leave empty) Used to establish a connection between the repository and a local folder (creation of a git folder under hidden files with the required information). You can insert a target location if you don't want to use the current folder or repository name.
git pull Use to (re-)download existing data in a repository to the local folder.
git status Use to check the status of synchronization.
git add -A Add files to the following commit (like a snapshot of edits). "-A" means all files and can be used for a full synchronization.
git commit -m "insert short name/description" Commits are snapshots of edits. If you push them to the repository, you can follow each edit and manage them like deleting one or merging some.
git push (origin/main or master) Uploads the commits including the edited files to the repository. Origin is used to specify where to upload the commit - don't have to use it if you are in the right folder.
git status If everything worked fine, it either states there is 100% synchronization or it lists exluded files (from commit).
git log Shows you a history all commits until a specific point. Exit by entering "q"
&& Used to combine commands. Usual workflow after cloning and checking status: git add -A && git commit -m "current date" && git push && git status
On Github.com: fork Extra: if you want to use a repository from other authors, use the fork command to create a copy you then can use to edit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment