-
创建新的branch:
git branch iss53
-
切换到一个branch:
git checkout iss53
-
查看所有本地branch:
git branch
-
比较两个branch(Head):
git diff branch1 branch2
-
重命名branch:
git branch (-m | -M) [<oldbranch>] <newbranch>
-
复制branch并重命名
git branch (-c | -C) [<oldbranch>] <newbranch>
-
删除branch:
git branch (-d | -D) [-r] <branchname>
-
舍弃修改:
git checkout -f
This will discard any local changes which are not committed in ALL branches and master.
With a -m or -M option, will be renamed to . If had a corresponding reflog, it is renamed to match , and a reflog entry is created to remember the branch renaming. If exists, -M must be used to force the rename to happen.
The -c and -C options have the exact same semantics as -m and -M, except instead of the branch being renamed, it will be copied to a new name, along with its config and reflog.
With a -d or -D option, will be deleted. You may specify more than one branch for deletion. If the branch currently has a reflog then the reflog will also be deleted.
Use -r together with -d to delete remote-tracking branches. Note, that it only makes sense to delete remote-tracking branches if they no longer exist in the remote repository or if git fetch was configured not to fetch them again. See also the prune subcommand of git-remote(1) for a way to clean up all obsolete remote-tracking branches.