命令
查看远程所有分支
git branch -a
1
2
3
4
5* dev
master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/release/caigou_v1.0新建分支并切换到指定分支
git checkout -b dev origin/release/caigou_v1.0
该命令可以将远程
git
仓库里的指定分支拉取到本地,这样就在本地新建了一个dev
分支,并和指定的远程分支release/caigou_v1.0
关联了起来。1
2Switched to a new branch 'dev'
Branch 'dev' set up to track remote branch 'release/caigou_v1.0' from 'origin'.查看本地分支及追踪的分支
git branch -vv
1
2* dev e67e3ef [origin/release/caigou_v1.0] 供应商详情页面
master 11160c2 [origin/master: behind 5] Merge branch 'master' of https://git.jointforce.com/scm/join/yj-stat*
表示当前所在分支,[远程分支]表示当前本地分支追踪的远程分支,最后一个是最近一次提交的注释。将本地分支推送到远程
git push -u origin dev:release/caigou_v1.0
成功后显示如下:
1
2
3
4
5
6
7
8
9
10
11
12Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 754 bytes | 754.00 KiB/s, done.
Total 8 (delta 6), reused 0 (delta 0)
remote:
remote: Create pull request for release/caigou_v1.0:
remote: https://git.jointforce.com/projects/JOIN/repos/yj-stat/compare/commits?sourceBranch=refs/heads/release/caigou_v1.0
remote:
To https://git.jointforce.com/scm/join/yj-stat.git
a22ed65..e8782b2 dev -> release/caigou_v1.0
Branch 'dev' set up to track remote branch 'release/caigou_v1.0' from 'origin'.上述命令表示将本地
dev
分支推送到远程release/caigou_v1.0
分支。