git Flashcards
Check what is waiting to be pushed
git status, OR:
git push –dry-run
Pull all branches
git pull –all
Switch to branch
git checkout branch
Merge from master to current branch, do commit
git merge master
Squash commits interactively
git rebase --interactive Opens vim. Read instructions. To change: i . edit first words in line as desired To exit change mode: esc To save and exit vim: :wq
Commit with message
git commit -m “msg”
Undo last commit, leave changes in working dir
git reset HEAD~1
Undo last commit, delete from working dir
git reset –hard HEAD~1
Fix last commit message
git commit -amend
Create a ‘negative’ of a commit that is already pushed
git revert [commit id] –no-commit
by default revert commits this negative
Add file to staging
git add [path]
Delete file from git
git rm [path]
Undo uncommitted changes
git checkout , OR
git reset HEAD
Cherry pick to current branch
git cherry-pick [commit id]
Merge to current branch without commit
git merge –no-commit