tec*_*yle 16 git version-control git-pull
我发现后者比第一个更快,所以git fetch
每当我需要将本地分支与远程同步时,我通常会这样做.有什么区别,如果有的话?
Pen*_*ian 27
以下命令:
git fetch
git reset --hard origin/<branch>
Run Code Online (Sandbox Code Playgroud)
将丢弃所有本地更改.
在哪里:
git pull
Run Code Online (Sandbox Code Playgroud)
这完全相同:
git fetch
git merge origin/<branch>
Run Code Online (Sandbox Code Playgroud)
将尝试保留当地的变化.
$ git pull
# takes the latest changes of origin/branch (exists both local & remote changes)
$ git reset --hard origin/branch
# replace your local with origin's branch history (discard local changes)
Run Code Online (Sandbox Code Playgroud)
示例:假设我们在 local 中有两个提交A
,B
而 remote 有两个提交A
, C
。现在,如果您拉动,那么您的本地将包含A
, B
,C
与如果重置不同,那么您的本地将拥有A
, C
not B
。
归档时间: |
|
查看次数: |
4707 次 |
最近记录: |