top of page

The Ultimate Git Commands Cheatsheet We Use Everyday



Yes even with code generators we all need git everyday. So outside of the regular git commit and pull / push here are things we all get stuck with and git commands cheatsheet to handle them.

Create & upload to new branch:

  • git checkout -b new_branch name

  • git add .

  • git commit -m “ Message”

  • git push origin branch

Connect server to git using SSH

  1. Create ssh key on local machine (ssh-keygen)

  2. Copy & paste public key to git. In bitbucket its added to your profile not a single repository

  3. On local machine run start ssh agent

eval $(ssh-agent)

Add ssh key to agent

ssh-add ~/.ssh/<private_key_file>

Test the ssh connect to bitbucket

ssh -T git@bitbucket.org

Get git to refresh repo after changing gitignore

  1. Make changes in .gitignore file.

  2. Run git rm -r --cached . command.

  3. Run git add . command

  4. git commit -m "Commit message" or just git commit or continue working.

Find all files with extension:

find /etc -name "*.conf"


Push all branches to new remote

git fetch --prune
git branch -r | grep -v '\\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git remote add upstream <the-url-path-of-a-remote.git>
git push --all upstream
git push --tags upstream

Upload large files to git

git config http.postBuffer 52428800

bottom of page