for sourcetree users
- list local branches
git branch
git fetch origin
git pull origin <branch>
(try with--ff-only
first, so you can bail or change things if merge or rebase is needed)git checkout <branch>
git checkout -b <branch> --track <remote>/<branch>
git merge --no-ff <branch>
git push --tags origin <branch>
- discard file
git checkout -- <path>
- discard everything
git reset --hard HEAD
- unstage file
git reset HEAD <path>
git branch <branch>
git add -i
ftwgit tag -l "v*"
git tag -a v0.0.0
git checkout --ours -- <paths>
https://stackoverflow.com/a/16826016/789893git mergetool
- p4merge: https://www.perforce.com/downloads/visual-merge-tool
git clean -dxn
- then
git clean -dxf
-n
is dry run-f
if force-x
is to clean ignored files
git stash list
git stash pop <stash>
, where<stash>
isstash@{0}
git stash save
===git stash
git stash -p
https://stackoverflow.com/a/17969785/789893
git show <commit>
git show <commit>:<file>
git log --stat -1 <commit>
git log --oneline --decorate --graph -5 HEAD
git log --oneline --decorate --graph --dirstat -5 HEAD
git log --oneline --decorate --graph --stat -1 <commit>
- search log by commit
git log --oneline --all --grep="find me"
--no-merges
--first-parent
git log --cherry master..<branch>
commits not yet merged to master https://kevinareed.com/2015/12/12/cherry-logging-git-branches/git cherry -v master <branch>
commits not yet merged to master- To list branches with commits not merged into master:
git branch --no-merged master
[core]
autocrlf = true
editor = code --wait
[log]
date = short
[format]
pretty = decoratedatename
[pretty]
decoratedatename = format:%C(auto,yellow)%h %C(auto,blue)%>(10,trunc)%ad %C(auto,green)%<(6,trunc)%ae%C(auto)%d %C(auto,reset)%s
[diff]
tool = p4merge
[merge]
tool = p4merge
[push]
default = upstream
[alias]
logg = log --graph
logf = log --first-parent
pullff = pull --ff-only
mergecommit = merge --no-ff
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
[difftool "sourcetree"]
cmd = 'C:/Program Files/Perforce/p4merge.exe' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
cmd = 'C:/Program Files/Perforce/p4merge.exe' \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
trustExitCode = true
[difftool "p4merge"]
cmd = 'C:/Program Files/Perforce/p4merge.exe' \"$LOCAL\" \"$REMOTE\"
[mergetool "p4merge"]
cmd = 'C:/Program Files/Perforce/p4merge.exe' \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
trustExitCode = true
gitpushmerge=git fetch && git checkout $1 && git pull && git push && git checkout $2 && git pull && git merge --no-ff $1 && git push && git checkout $1