Git使用笔记
此处记录了一些git使用的笔记 显示本地未push的commits git log origin.. git log origin/master..HEAD 恢复到某一个commits git reset d6e63190 git reset --soft HEAD@{1} git commit -m 'reset to xxxx' #Update working copy to reflect the new commit git reset --hard update a branch without checkout it git checkout dev; # now in dev branch git fetch origin master:master; remove any old, conflicting branches git remote prune origin diff of local branch and remote branch git fetch origin git diff dev origin/dev git show history git log --oneline --decorate --graph --all git log --name-status git log --stat git log --stat --pretty=short --graph # 显示详细的改动信息 git log -p # 用patch的形式显示最后一次commit git log -p HEAD^..HEAD delete tag git push origin :tagname git push --delete origin tagname git tag --delete tagname bundle git bundle create ../my-db.bundle d7e11e3bd..HEAD git bundle create ../my-db.bundle --since=10.days master move back to where the origin is git reset --hard origin/develop reset to previous version git reset --hard 56e05fced git reset --soft HEAD@{1} git diff --cached git commit show git version git describe git describe --tags git deploy #https://grimoire.ca/git/stop-using-git-pull-to-deploy git fetch --all git checkout --force origin/master git checkout --force 63d0a6c git checkout --force v5.2 set local branch track to upstream git branch --set-upstream ssl-test origin/ssl-test show git commit hash git rev-parse --short HEAD archive git archive master | tar -x -C /somewhere/else git archive --format zip --output /full/path/to/zipfile.zip master git archive master | gzip > latest.tgz diff, current head to some branch git diff HEAD master reset local branch to origin branch # https://gist.github.com/Chaser324/ce0505fbed06b947d962 git fetch origin git reset --hard origin/master git clean -f grep in history git grep TODO $(git rev-list --all) # 显示涉及到这个关键字的提交 git log -G TODO # 显示涉及到这个关键字的提交,并显示diff git log -p -G TODO set master to a branch. # https://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch git checkout seotweaks git merge -s ours master git checkout master git merge seotweaks abort a merge git merge --abort checkout remote branch git checkout -t origin/ipv6 设置alias git config --global --add alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" git lg rebase git fetch upstream git checkout master git rebase upstream/master git push -f origin master 显示被忽略的文件 git status --ignored 列出文件的最后一次提交时间 git ls-tree -r --name-only HEAD | while read filename; do echo "$(git log -1 --format="%ai" -- $filename) $filename" done submodule git submodule init git submodule update --rebase --remote 个人仓库开发 git clone [email protected]:abc/xyz.git xyz git remote add upstream XXXXX git fetch upstream git checkout -b fix-xxx upstream/master git commit -a -m 'change ...‘ git push origin fix-xxx 恢复master git fetch upstream git checkout master git rebase upstream/master git push -f origin master 克隆大仓库 可以先设置depth=1 ...