mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 18:43:52 +00:00
2.2 KiB
2.2 KiB
Git Cheat Sheet (Detailed)
See also fixing commits
Commands:
- add
git add foo.py: addfoo.pyto the staging areagit add foo.py bar.py: addfoo.pyANDbar.pyto the staging area
- checkout
git checkout -b new-branch-name: create branchnew-branch-nameand switch/checkout to that new branchgit checkout master: switch to yourmasterbranchgit checkout old-branch-name: switch to an existing branchold-branch-name
- commit
git commit --amend: changing the last commit message. Read more here
- config
git config --global core.editor nano: set core editor tonano(you can set this tovimor others)git config --global core.symlinks true: allow symbolic links
- diff
git diff: display the changes you have made to all filesgit diff --cached: display the changes you have made to staged filesgit diff HEAD~2..: display the 2 most recent changes you have made to files
- fetch
git fetch origin: fetch origin repositorygit fetch upstream: fetch upstream repository
- grep
git grep update_unread_counts -- '*.js': search all files (ending in.js) forupdate_unread_counts
- log
git log: show commit logs
- pull
- do not use for Zulip
- push
git push origin +branch-name: push your commits to your origin repository
- rebase
git rebase -i HEAD~3: interactive rebasing current branch with first three items on HEADgit rebase -i master: interactive rebasing current branch with master branchgit rebase upstream/master: rebasing current branch with master branch from upstream repository
- reflog
git reflog | head -10: manage reference logs for the past 10 commits
- remote
git remote -v: display your origin and upstream repositories
- reset
git reset HEAD~2: reset two most recent commits
- rm
git rm oops.txt: removeoops.txt
- show
git show HEAD: display most recent commitgit show HEAD~~~: display third most recent commitgit show master: display most recent commit onmaster
- status
git status: show the working tree status, unstaged and staged files