git 专贴
git 大部分的命令都是涉及自身的repository,只有少数几个命令是与其他仓库交互的。其中常见的是:fetch
pull
push
clone
等等。
[[i] 本帖最后由 弯月圆刀 于 2008-10-8 08:46 编辑 [/i]] 下面看一下reset的运作。
这是当前的gitk图示,接下来我要将master reset到more ignore这个节点。
[attach]933[/attach]
执行reset命令:
[attach]936[/attach]
这是命令之后:
[attach]934[/attach]
[attach]935[/attach] git fetch origin todo:my-todo-work
The first argument, "origin", just tells git to fetch from the repository you originally cloned from. The second argument tells git to fetch the branch named "todo" from the remote repository, and to store it locally under the name refs/heads/my-todo-work.
git fetch git://example.com/proj.git +master:refs/remotes/example/master
Note the addition of the "+" sign. Alternatively, you can use the "-f" flag to force updates of all the fetched branches, as in: 如果git capistrano发生如下错误:
Password:
[m.m3958.com] executing command
** [out] sh: git: command not found
command finished
并且你已经在服务器上面安装了git。一个可能的原因就是,capistrano是用的shell是sh,而我们linux下面默认的是bash,所以新建一个ln可能会解决这个问题。
ln -s /usr/local/bin/git /usr/bin/git
就可以了。 git里面的所有refs实际上是指向一个commit。
而且,所有的branch的名称是针对自己的repository来说的,根本不用在乎远程的branch的名称。每个仓库都是针对自己。
所以当你执行:
git pull [email]git@github.com[/email]:jianglibo/fao.git yui2.6.0
标准的pull命令:
git pull <options> <repository> <refspec>…
其中<refspec> parameter is +?<src>:<dst>
所以上面的命令如果写全的话是:git pull [email]git@github.com[/email]:jianglibo/fao.git yui2.6.0:yui2.6.0
就是将远程的仓库中的yui2.6.0,拉下来很本地仓库的yui2.6.0合并。
如何在远程repository建立新的branch
git push origin master:refs/heads/experimentalorigin是push的对象。
后面的是ref的格式:
<refspec>…
The canonical format of a <refspec> parameter is +?<src>:<dst>; that is, an optional plus +, followed by the source ref, followed by a colon :, followed by the destination ref.
The <src> side represents the source branch (or arbitrary "SHA1 expression", such as master~4 (four parents before the tip of master branch); see git-rev-parse(1)) that you want to push. The <dst> side represents the destination location.
The local ref that matches <src> is used to fast forward the remote ref that matches <dst> (or, if no <dst> was specified, the same ref that <src> referred to locally). If the optional leading plus + is used, the remote ref is updated even if it does not result in a fast forward update.
tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.
A parameter <ref> without a colon pushes the <ref> from the source repository to the destination repository under the same name.
Pushing an empty <src> allows you to delete the <dst> ref from the remote repository.
The special refspec : (or +: to allow non-fast forward updates) directs git to push "matching" heads: for every head that exists on the local side, the remote side is updated if a head of the same name already exists on the remote side. This is the default operation mode if no explicit refspec is found (that is neither on the command line nor in any Push line of the corresponding remotes file---see below).
页:
[1]
