A designer's git cheatsheet.
I wrote this cheatsheet while learning to use git. It has served as a personal reference many times so I'm making it available here.
git log
see all recent updates
`git commit -m "your commit message here"`
Amending small updates to previous commit:
- Make necessary updates
git add -A
git commit --amend --no-edit
(adds update to your latest commit)git push --force
Amend a commit without opening vim(text editor):
`git commit --amend --no-edit`
git stash
git stash list
(displays list)
git stash apply
(applies most recent stash)
git stash apply stash@{n}
(stash specific version)
git stash clear
(clears all)
On local
git branch -D branchname
On remote
git branch -dr origin/branchname
git branch -m oldname newname
git reset --hard HEAD^
(rewinds changes)
Reset author date: git commit --amend --date=now
Reset author date w/o opening vim:git commit --amend --no-edit --date=now
Reset author of the last commit:git commit --amend --reset-author --no-edit
In case of merge conflict:
- Fix conflict
git add
git rebase --continue
(No need to commit again)
Git rebase -i branchname
- Pick any line and [squash] anything you want to apply to the first line.
- Esc + :wq
- Edit commit message
- Esc + :wq
git rm -r --cached filename