git操作分支

//远程创建了分支 这时候下面看不到

lyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (master)

$ git branch -a
* master
  –als
  remotes/origin/HEAD -> origin/master
  remotes/origin/master


flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (master)
$  git branch
* master
  –als


flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (master)
$  git branch -a
* master
  –als
  remotes/origin/HEAD -> origin/master
  remotes/origin/master


//pull之后才能看到远程新创建的分支


flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (master)
$ git pull
From code.aliyun.com:13701969163/bimatrixweb
 * [new branch]      fenzhi1    -> origin/fenzhi1
Already up-to-date.


flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (master)
$  git branch -a
* master
  –als
  remotes/origin/HEAD -> origin/master
  remotes/origin/fenzhi1
  remotes/origin/master


flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (master)



//git branch -a 查看所有分支

flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (fenzhi1)
$ git branch -a
* fenzhi1
  master
  –als
  remotes/origin/HEAD -> origin/master
  remotes/origin/fenzhi1
  remotes/origin/master


//修改git仓库一个分支下的文件 然后提交 TEST.txt 内容 从hello修改为 hello git
flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (fenzhi1)
$ git add .



flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (fenzhi1)
$ git commit -m "add test.txt hello git fenzhi"
[fenzhi1 1e3c0a4] add test.txt hello git fenzhi
 1 file changed, 1 insertion(+), 1 deletion(-)


flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (fenzhi1)
$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 276 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1)
remote: Updating references: 100% (1/1)
To code.aliyun.com:13701969163/bimatrixweb.git
   1087c0c..1e3c0a4  fenzhi1 -> fenzhi1


flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (fenzhi1)
$ git branch -a
* fenzhi1
  master
  –als
  remotes/origin/HEAD -> origin/master
  remotes/origin/fenzhi1
  remotes/origin/master


//切回到master下面   TEST.txt 内容仍然是hello                  git就是这样一个仓库下面控制所有的分支 。。。

//通过切换分支 实现代码的改变
flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (fenzhi1)
$ git checkout  master
Switched to branch 'master'
M       README.md
Your branch is up-to-date with 'origin/master'.


flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (master)
$ git checkout fenzhi1
Switched to branch 'fenzhi1'
M       README.md
Your branch is up-to-date with 'origin/fenzhi1'.


//切回到主分支master  把fenzhi1合并到master上面。。

flyer@revit MINGW64 /d/javaproject/gitstore/bimatrixweb (master)
$ git merge fenzhi1
Updating 1087c0c..1e3c0a4
Fast-forward
 TEST.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


http://blog.csdn.net/albertfly/article/details/63262427

你可能感兴趣的:(git)