git Flashcards
(36 cards)
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
Reset types
- -soft: discard last commit, leave in staging area,
- -mix: discard last commit and add, leave in working folder,
- -hard: discard last commit, add and any changes to HEAD
Show remote names
git remote
What is the diff between pull and fetch?
pull = fetch + merge
Add remote
git remote add [shortname] [url]
Create branch
git checkout -b iss53
This is shorthand for:
git branch iss53
git checkout iss53
Global option to rebase when pulling
git config –global pull.rebase “true”
Pull from a specified remote
git pull [options] [remote name]
What is a ‘bare’ repo?
A Git repository that has no working directory
What is the diff between pull and fetch?
pull = fetch + merge