sh Git Branch Housekeeping

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Git Branch Housekeeping相关的知识,希望对你有一定的参考价值。

# Reference -- http://railsware.com/blog/2014/08/11/git-housekeeping-tutorial-clean-up-outdated-branches-in-local-and-remote-repositories/

# show information about origin
git remote show origin

# check merged/not merged local banches
git checkout master
git branch --merged (list branches merged with current branch)
git branch --no-merged (list branches not merged with current branch)

# delete branch
git branch -d {branch_name}
git branch -D {branch_name} (forced delete, probably for branches that have not been merged)

# delete remote branch
git push origin :{branch_name}
git push origin --delete {branch_name} (As of Git v1.7.0)

# clean-up outdated references
git remote prune origin

# rename local branch 
git branch -m new-name (if on current branch to rename)
git branch -m old-name new-name (if on another branch)

# delete the old-name remote branch and push the new-name local branch
git push origin :old-name new-name

# reset the upstream branch for the new-name local branch
git push origin -u new-name

# set up branch to track remote branch spring from origin
git branch --set-upstream-to origin/spring

以上是关于sh Git Branch Housekeeping的主要内容,如果未能解决你的问题,请参考以下文章

sh Git Branch Regex

sh Git Branch Housekeeping

sh Git Branch

sh Import_new_remote_git_branch.sh

sh Longform-git-branch-tracking-commands.sh

sh 在命令行上显示git branch,并为常用命令显示git别名