Git 命令 创建与合并分支, 查找commit分支

创建与合并分支

1.  创建分支 

     git  branch name

本地创建,创建远程关联远程

方法a:

git push --set-upstream origin master

方法b:

  *新分支传到远程

tiaxia@TIAXIA8 MINGW64 /c/Workspace/project/UIHouston/VPC-IDM-ADMIN (sonar_code_review)
$ git push origin sonar_code_review
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 389 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To git@github.houston.entsvcs.net:VPC-RnD/VPC-IDM-ADMIN.git
 * [new branch]      sonar_code_review -> sonar_code_review

别人此时可以看到此远程分支,并且修改之后,本地还获取不了此修改,如此时pull

tiaxia@TIAXIA8 MINGW64 /c/Workspace/project/UIHouston/VPC-IDM-ADMIN (sonar_code_review)
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
    git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
    git branch --set-upstream-to=origin/<branch> sonar_code_review
如下操作修复:

tiaxia@TIAXIA8 MINGW64 /c/Workspace/project/UIHouston/VPC-IDM-ADMIN (sonar_code_review)
$ git branch --set-upstream-to=origin/sonar_code_review sonar_code_review
Branch sonar_code_review set up to track remote branch sonar_code_review from origin.


tiaxia@TIAXIA8 MINGW64 /c/Workspace/project/UIHouston/VPC-IDM-ADMIN (sonar_code_review)
$ git status
On branch sonar_code_review
Your branch and 'origin/sonar_code_review' have diverged,
and have 1 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean


tiaxia@TIAXIA8 MINGW64 /c/Workspace/project/UIHouston/VPC-IDM-ADMIN (sonar_code_review)
$ git pull
Merge made by the 'recursive' strategy.
 idm-admin-api/api/no_timeout_forward.js              |  2 +-
 idm-admin-api/api/util/authTypes.js                  |  4 ++--
 idm-admin-app/bin/migrate.js                         |  1 -
 idm-admin-app/npm/link.js                            |  3 ---
 idm-admin-ui/app/home/home.controller.js             |  2 +-
 idm-admin-ui/app/import/base.controller.js           |  3 +--
 idm-admin-ui/app/import/step1.controller.js          |  2 +-
 .../app/organization/account/account.controller.js   |  5 +----
 .../organization/account/create.modal.controller.js  |  8 ++++----
 idm-admin-ui/app/utils/string.util.js                | 20 +++++++++++++++-----
 10 files changed, 26 insertions(+), 24 deletions(-)

 

2.  切换分支

     git checkout name

3. 1+2 

     git checkout -b name

     (git checkout -b newBranchName a9c146a09505837ec03b)

4. 合并分支

    git merge name

5. 删除分支

    git branch -d name

6. 查看分支

   git branch

 

例子("feature/v1.1.1_dev"合并到"master"):

10@10-PC /e/Workshop/IDBBOND/systempreferenceserver (master)

$ git branch

  feature/v1.1.1_dev

* master

 

 

10@10-PC /e/Workshop/IDBBOND/systempreferenceserver (master)

$ git merge feature/v1.1.1_dev

Updating 0000fc6..0158980

Fast-forward

 .gitignore                                                | 2 ++

 SystemPreferenceServer/Requests/trader_request_handler.py | 4 ++++

 2 files changed, 6 insertions(+)

 

 

10@10-PC /e/Workshop/IDBBOND/systempreferenceserver (master)

7. 把分支推到远程分支 

 git push origin newLocalBranch

8. 查找commit所在branch
EAD+xtian5@CNCND6040MB3 MINGW64 /c/Workshop/dev/backend/VPC-IDM-service ((d4a0f5116...))
$ git branch -r --contains ab074e159ac0926e72f72ddead12eda2aef45e5f
  origin/saml_demo

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值