This cheat sheet is not for beginners learning Git. Instead, it is a simple "here's all the most used commands" for when you inevitably forget one or two.
Table of Contents
You should really know this already. I added it just to cover all the frequently used commands
git init
NOTE: This does not actually download said changes
git fetch
git pull
git clone <url>
git status
git add .
git commit -m "Comment"
git stash
git stash pop
To see all available config options refer to the git config documentation
git config --global user.name "username"
If using GitHub, you can use the noreply email <username>@users.noreply.github.com
git config --global user.email "email@example.com"
For more information check out git-scm.com's branch and merging page
git checkout -b my-new-branch
-u
can also be used instead of --set-upstream
git push --set-upstream <upstream> my-new-branch
Typically, <upstream>
is origin
git checkout my-branch
This will take the changes in your current branch and merge them with branch-to-merge-into
git merge branch-to-merge-into
git fetch
Used to store large files separately from remote repo. See here for more info
git lfs install
This tracks all .psd
files.
git lfs track "*.psd"
This causes the .gitattributes
to be updated. Add this to the repo via
git add .gitattributes
Information obtained from here
git submodule add git@github.com:url_to/my-submodule.git repo-path-to-submodule
cd
into said module and use regular git commands
git submodule update