🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
创建分支:git branch branchname ~~~ $ git branch new_branch Administrator@MY-PC /D/worksp/sample (master) ~~~ 显示本地分支列表:git branch ~~~ $ git branch * master new_branch ~~~ 切换分支:git checkout branchname ~~~ $ git checkout new_branch M src/string.py Switched to branch 'new_branch' ~~~ 创建和切换分支的快捷方式: 在上面的例子中,分别使用两个命令创建和切换分支。 Git为checkout命令提供-b选项; 此操作将创建一个新的分支,并立即切换到新分支。 ~~~ $ git checkout -b test_branch M src/string.py Switched to a new branch 'test_branch' Administrator@MY-PC /D/worksp/sample (test_branch) ~~~ 显示本地分支列表:git branch ~~~ $ git branch master new_branch * test_branch ~~~ 删除分支 可以通过向git branch命令提供-D选项来删除分支。 但在删除现有分支之前,请切换到其他分支。 如上面所示,目前在test_branch分支,如要想删除该分支。需要先切换到其它分支再删除此分支,如下所示。 ~~~ $ git branch master new_branch * test_branch Administrator@MY-PC /D/worksp/sample (test_branch) ~~~ 先切换到其它分支: ~~~ $ git checkout master M src/string.py Switched to branch 'master' Your branch is ahead of 'origin/master' by 4 commits. (use "git push" to publish your local commits) Administrator@MY-PC /D/worksp/sample (master) ~~~ 删除分支 ~~~ $ git branch -D test_branch Deleted branch test_branch (was b759faf). Administrator@MY-PC /D/worksp/sample (master) ~~~ 当前剩下的分支如下 - ~~~ $ git branch * master new_branch ~~~ 当前剩下的分支如下 - ~~~ $ git branch * master new_branch ~~~ 重命名分支 假设需要在项目中添加对宽字符的支持。并且已经创建了一个新的分支,但分支名称需要重新命名。那么可通过使用-m选项后跟旧的分支名称和新的分支名称来更改/重新命名分支名称。 ~~~ $ git branch * master new_branch Administrator@MY-PC /D/worksp/sample (master) ~~~ 重命名分支 ~~~ $ git branch -m new_branch wchar_support ~~~ 现在,使用git branch命令显示新的分支名称。 ~~~ $ git branch * master wchar_support ~~~ 将远程共享服务器的改动获取到本地并和本地提交合并:git pull * * * * * https://www.yiibai.com/git/git_managing_branches.html