but not often, so I forget
Most common commands are covered in atlassian's gitflow documentation and this medium post
git docs
atlassian docs
update remote tracking branches
update remote tracking branches
git fetch --all
see what will happen
git fetch --all --dry-run
list local and remote branches
git branch -a
list remote only
git branch -r
When checking out a remote branch that has no local tracking branch yet In version 2 of git this is the same as switcing between local branches
git checkout <remote branch name>
git reflog
Sometimes I want to review changes on the remote branch before merging with my local branch with a git pull
this seems to not always show changes. Need to investigate.
fetch remote changes. This will only update the local copy of the remote branch, but not the local branch
git fetch
specify branch to compare to
git diff origin/develop
if good with all of the differences then merge to local copy like this
git pull --rebase origin develop
This seems like a safer way, but I haven't tried it yet
git checkout branchA
git merge -X theirs branchB
DANGER!!! this will throw away all local changes commit not on remote
pull down remove branches - do not merge with local working tree
git fetch --all
point local working tree to origin commit of remote branch throwing away local changes
git reset --hard origin/<branch-name>
purge untracked or ignored files from the local tree
`git clean -fdx
Haven't figured this out yet really
list files with conflicts
git diff --name-only --diff-filter=U
If using git flow and wanted to delete remote branch when finished with feature or release use -F Normally there would not be a remote branch except for develop and master
git flow finish feature SMH-201 -F
remote branch
git push -d origin <branch_name>
local branch
git branch -d branch_name
force delete local branch
git branch -D branch_name
following this blog and this blog
remove all files from local tracking
git rm -r --cached .
add them again honoring the changed .gitignore files in the working tree that should be ignored will be deleted
git add .
git commit -m "Clean up ignored files"
basic useful view
git log
one I use a lot
git log --graph --oneline --decorate -10
formatting
each commit on a single line
git log --oneline
single line with merges and tags - NICE!
git log --oneline --decorate
single line with ascii merge tree - NICER!
git log --graph --oneline --decorate
inserts and deletes to files
git log --stat
get a summary of changes by author
git shortlog
detailed specification of output useful when piping to other commands
git log --pretty=format:"%cn committed %h on %cd"
filtering
three commits
git log -3
commits since yesterday
git log --after="yesterday"
by author
git log --author="Umar*"
by commit message ignore case
git log -i --grep="JRA-224:"
changes to specific files
git log -- logging.yml