git 的分支使用

之前师兄在git上创建了一个新的branch,自己看到了,不过没怎么记得操作,后来师兄帮忙弄了一下,也是了解了一些大概

先交上代码,最近有点忙,随后有时间再添加注释,下面是dos窗口的一些命令。(主要是关于pull中的fetch跟merge,以及创建远程分支的track)

具体还是需要看廖雪峰的Git教程,很详细也很全,还有一个很不错的网址,可以参考

Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。

C:UsersigMan.huizh>的:
'的:' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:UsersigMan.huizh>d:

D:>cd www

D:WWW>cd reportv2

D:WWW
eportv2>git branch
* master

D:WWW
eportv2>git branch -a -v
* master                210b0ae add MY_Model.php
  remotes/origin/HEAD   -> origin/master
  remotes/origin/master 210b0ae add MY_Model.php

D:WWW
eportv2>git fetch origin graph
remote: Counting objects: 88, done.
remote: Compressing objects: 100% (60/60), done.
error: RPC failed; result=56, HTTP code = 200
ffatal: early EOF
atal: The remote end hung up unexpectedly
fatal: unpack-objects failed

D:WWW
eportv2>git fetch origin graph
remote: Counting objects: 88, done.
remote: Compressing objects: 100% (60/60), done.
^Cpacking objects:  54% (48/88)
D:WWW
eportv2>git branch -a -v
* master                210b0ae add MY_Model.php
  remotes/origin/HEAD   -> origin/master
  remotes/origin/master 210b0ae add MY_Model.php

D:WWW
eportv2>git pull
remote: Counting objects: 88, done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 88 (delta 49), reused 61 (delta 22)
Unpacking objects: 100% (88/88), done.
From https://github.com/zhangbobell/reportv2
 * [new branch]      graph      -> origin/graph
Already up-to-date.

D:WWW
eportv2>git branch
* master

D:WWW
eportv2>git branch -a -v
* master                210b0ae add MY_Model.php
  remotes/origin/HEAD   -> origin/master
  remotes/origin/graph  9060e1f finish all the line chart with single line
  remotes/origin/master 210b0ae add MY_Model.php

D:WWW
eportv2>git fetch origin graph
From https://github.com/zhangbobell/reportv2
 * branch            graph      -> FETCH_HEAD

D:WWW
eportv2>git branch -a -v
* master                210b0ae add MY_Model.php
  remotes/origin/HEAD   -> origin/master
  remotes/origin/graph  9060e1f finish all the line chart with single line
  remotes/origin/master 210b0ae add MY_Model.php

D:WWW
eportv2>git checkout --track origin/graph
error: Your local changes to the following files would be overwritten by checkou
t:
        application/core/MY_Model.php
Please, commit your changes or stash them before you can switch branches.
Aborting

D:WWW
eportv2>git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   application/controllers/management.php
        modified:   application/core/MY_Model.php
        deleted:    public/images/captcha/1416399365.4974.jpg
        modified:   public/js/management/project_edit.js

no changes added to commit (use "git add" and/or "git commit -a")

D:WWW
eportv2>git status application/controllers/management.php
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   application/controllers/management.php

no changes added to commit (use "git add" and/or "git commit -a")

D:WWW
eportv2>git checkout -- application/controllers/management.php

D:WWW
eportv2>git checkout -- public/js/management/project_edit.js

D:WWW
eportv2>git checkout -- application/core/MY_Model.php

D:WWW
eportv2>git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        deleted:    public/images/captcha/1416399365.4974.jpg

no changes added to commit (use "git add" and/or "git commit -a")

D:WWW
eportv2>git branch
* master

D:WWW
eportv2>git branch -a -v
* master                210b0ae add MY_Model.php
  remotes/origin/HEAD   -> origin/master
  remotes/origin/graph  9060e1f finish all the line chart with single line
  remotes/origin/master 210b0ae add MY_Model.php

D:WWW
eportv2>git checkout --track origin/graph
Branch graph set up to track remote branch graph from origin.
Switched to a new branch 'graph'

D:WWW
eportv2>git branch -a -v
* graph                 9060e1f finish all the line chart with single line
  master                210b0ae add MY_Model.php
  remotes/origin/HEAD   -> origin/master
  remotes/origin/graph  9060e1f finish all the line chart with single line
  remotes/origin/master 210b0ae add MY_Model.php

D:WWW
eportv2>^A

 第二段:dos界面下解决每次都是pull失败的情形

D:WWW>cd reportv2

D:WWW
eportv2>ls
LICENSE  README.md  application  index.php  jt_usage.md  public  system

D:WWW
eportv2>git status
On branch graph
Your branch is up-to-date with 'origin/graph'.

nothing to commit, working directory clean

D:WWW
eportv2>git branch -a -v
* graph                 bfa864e Updated the develop plan
  master                210b0ae add MY_Model.php
  remotes/origin/HEAD   -> origin/master
  remotes/origin/graph  bfa864e Updated the develop plan
  remotes/origin/master 210b0ae add MY_Model.php

D:WWW
eportv2>git pull
Already up-to-date.

D:WWW
eportv2>

 

原文地址:https://www.cnblogs.com/zh9927/p/4113896.html