Skip to content

Instantly share code, notes, and snippets.

@ramesaliyev
Last active October 23, 2019 12:18
Show Gist options
  • Save ramesaliyev/6ed8d142e2c2f22228c7 to your computer and use it in GitHub Desktop.
Save ramesaliyev/6ed8d142e2c2f22228c7 to your computer and use it in GitHub Desktop.
Git Cheat Sheet
- Create a repository
git init <repo-name>
git clone <url> <directory-name>
git clone -o <remote-name> <url>
- Commiting
git add <filename>
git commit -m "Commit Message"
git commit -am "Commit Message"
git commit --amend --date="now"
- Uncommit
git reset --soft HEAD^
- Remote
git remote
git remote show <remote-name>
git remote add <remote-name> <remote repository URL>
git push <remote-name> <branch-name>
- Branch
git branch <branch-name>
git branch -d <branch-name> (delete)
git push origin :<branch-name> (delete from remote)
git checkout <branch-name>
git checkout -b <branch-name> (create and switch)
git push origin <local-branch-name>:<remote-branch-name> (push to remote with different name)
git merge <branch-name> (merge branch to current)
- Merge
git merge <branch-to-merge>
- Reset
git log
git checkout <commit-id>
git reset HEAD --hard
- Credentials
git config credential.helper store
- Other Configs
git config --global push.default simple
- Setup Configs
git config --global user.name "John Doe"
git config --global user.email "john@doe.com"
- Disable backup .orig files
git config --global mergetool.keepBackup false
- Disable pager for branch command
git config --global pager.branch false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment