标签: git-pull

Git pull取决于当前的dir

我正在git pull通过root用户从任何目录尝试某个存储库.

例如,在执行git pull/root/:

#> cd ~
#> sudo -u dmalikov git --git-dir=/home/dmalikov/path/to/repo/.git pull 
/usr/libexec/git-core/git-sh-setup: line 142: cd: /root/.: Permission denied
Cannot chdir to /root/., the toplevel of the working tree
Run Code Online (Sandbox Code Playgroud)

并执行git pull来自/:

#> cd /
#> sudo -u dmalikov git --git-dir=/home/dmalikov/path/to/repo/.git pull 
Already up-to-date.
Run Code Online (Sandbox Code Playgroud)

为什么当前目录会影响git pull命令?

如何cd避免多余的?

git git-pull

18
推荐指数
1
解决办法
1万
查看次数

如何以编程方式快进单个git提交?

我定期从git获取看起来像这样的消息:

Your branch is behind the tracked remote branch 'local-master/master' 
by 3 commits, and can be fast-forwarded.
Run Code Online (Sandbox Code Playgroud)

我希望能够在shell脚本中编写命令,可以执行以下操作:

  1. 如何判断我当前的分支是否可以从它正在跟踪的远程分支快进?

  2. 如何判断我的分支"后面"有多少提交?

  3. 如何通过一次提交快进,以便例如,我的本地分支将从"后面的3次提交"变为"后面的2次提交"?

(对于那些感兴趣的人,我正在尝试组合一个高质量的git/darcs镜像.)

git git-pull fast-forward

17
推荐指数
3
解决办法
2万
查看次数

Git说,从遥控器拉出后,当地分公司处于远程领先地位

如果标题不清楚我很抱歉,但这是一个奇怪的问题.

git checkout到我的"舞台"分支并git pull获得我的合作伙伴的最新更改(他昨晚推送到远程存储库的"舞台"分支),果然,他们合并到我当地的"舞台"分支.git log <branch>显示他昨晚进行的五次提交.

然后我切换到master分支从repo中取出它,因为他告诉我他在测试后将这些更改合并到master分支.但是当我git checkout stage回到我的"舞台"分支时,它表示我已经通过5次提交领先于远程分支.我git log origin/stage和它只显示了我刚从该存储库中提取的五个提交(该项目中唯一的远程存储库).git log stage在我当地的"舞台"分支上显示了五个提交,所以我在为我的合作伙伴的最新提交服务后立即回复远程分支机构的时候我感到很遗憾.

我对此非常陌生,所以我很感激你对我的耐心,因为我还在努力掌握DCVS,而且我很有可能只是误解了一些非常基本的东西.

git commit git-pull

17
推荐指数
1
解决办法
1万
查看次数

"git pull --rebase"导致"无法重组到多个分支"

所以,我的工作环境恰好有一个分支,在Github上有一个远程伴侣.我正在尝试这样做git pull --rebase,以防止git push创建合并提交消息,这些消息不向处理此项目的其他人提供新信息,只是搞砸了工作.但是当我尝试这个时,它给了我这个:

From https://github.com/our_profile/our_repository
 * branch            HEAD        -> FETCH_HEAD
Cannot rebase onto multiple branches
Run Code Online (Sandbox Code Playgroud)

拉动中止.打电话git branch通知我,我的本地机器上只有一个分支,所以发生了什么?

git branch github git-pull git-rebase

17
推荐指数
2
解决办法
7971
查看次数

设备上没有剩余空间

我做了git pull --rebase,我得到了以下错误:

 error: file write error (No space left on device)
 fatal: unable to write sha1 file 
 fatal: unpack-objects failed
Run Code Online (Sandbox Code Playgroud)

我的设备上有很多空间.不知道为什么会出现这个错误.我第一次遇到这个错误.有没有人面对这个问题?

谢谢.

git git-pull git-rebase

17
推荐指数
3
解决办法
2万
查看次数

为什么git拉挂?

当我做一个git pull,从git bash,终端通常运行拉,更新我的本地,然后挂起.我不确定它是否在等我做某事,但我通常会退出CTRL-C.之后,我得到一个index.lock阻止我做其他我必须删除的东西.我误解了怎么git pull运作?

git git-pull git-bash

17
推荐指数
8
解决办法
2万
查看次数

没有参数的Git获取和拉取

我有一个名为git branch的签出foo.

> git status
# On branch foo
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)

它最初使用此命令检出:

> git checkout origin/foo -b foo --track
Run Code Online (Sandbox Code Playgroud)

我想从远程存储库获取此分支的更新.我知道这些命令中的任何一个都足够了:

> git fetch origin foo # ignore the lack of merging
> git pull origin foo
Run Code Online (Sandbox Code Playgroud)

如果我省略了fetchor 的参数pull,git默认会获取(或拉动)我当前检出的分支?也就是说,以下两对命令是否等效?

> git checkout foo
> git pull
Run Code Online (Sandbox Code Playgroud)

> git checkout foo
> git pull origin foo
Run Code Online (Sandbox Code Playgroud)

git git-pull git-fetch

16
推荐指数
2
解决办法
9100
查看次数

如何修复被中断的git fetch破坏的git存储库?

如果git fetch被例如Ctrl-C中断或由连接问题引起,那么之后git fetchgit pull无法工作.

user@computer:~/code/openttd-git$ git fetch
^C
user@computer:~/code/openttd-git$ git fetch
error: Unable to find 22d90742fc79a9011fb86ee03d8aeea66bc12657 under http://git.openttd.org/openttd/trunk.git
Cannot obtain needed object 22d90742fc79a9011fb86ee03d8aeea66bc12657
error: Fetch failed.
Run Code Online (Sandbox Code Playgroud)

我相信这与存储库无关.使用git clone创建这个破碎的本地资源库的拷贝到一个新的本地存储库不解决这个问题.到目前为止,我所知道的唯一解决方案是git clone将整个远程存储库(origin/master)转换为新的本地存储库.但是有没有更好(更快)的解决方案?

Debian的bug报告有最后的消息,从2011年2月这是相同的错误我还是有已经有修补程序或任何解决方案或解决方法呢?我的git版本是1.7.10.

git git-pull git-fetch

16
推荐指数
2
解决办法
1万
查看次数

为什么git log在git fetch之后没有显示任何新内容?

我正在学习如何通过阅读Pro Git Book相关部分来使用Git遥控器.

如果克隆存储库,该命令会自动以名称"origin"添加该远程存储库.因此,git fetch origin从您克隆(或最后从中获取)之后,获取已推送到该服务器的任何新工作.

请务必注意,该git fetch命令仅将数据提取到本地存储库; 它不会自动将其与您的任何工作合并或修改您当前正在处理的工作.准备好后,您必须手动将其合并到您的工作中.

这是我试过的.我克隆了一个存储库并编辑了一个文件.在原始存储库中,有人更新了同一个文件并推送.然后,

  1. 我跑git fetch.它显示了一些更新进度消息.但是,git log没有显示更新.我误解了什么git fetch吗?我错过了什么吗?

  2. 我跑了git pull,我得到了

错误:您对"hello_world.c"的本地更改将被合并覆盖.中止.请在合并之前提交更改或存储更改.

在这里,我相信它也在合并并避免意外数据丢失,它会中止.

编辑: 谢谢你的回答.实际上在查看答案之前,我正在尝试自己,并通过以下命令/输出实现了相同的功能:

$ git ls-remote origin
d0006a6bfa95e0e90aa820a0e50d31a548625652    HEAD
d0006a6bfa95e0e90aa820a0e50d31a548625652    refs/heads/master
$ git ls-remote .
14375458b8a6b84f82d9fa4d2ded0bb8c9e87431    HEAD
14375458b8a6b84f82d9fa4d2ded0bb8c9e87431    refs/heads/master
d0006a6bfa95e0e90aa820a0e50d31a548625652    refs/remotes/origin/HEAD
d0006a6bfa95e0e90aa820a0e50d31a548625652    refs/remotes/origin/master
Run Code Online (Sandbox Code Playgroud)

还有以下命令:

$git log origin --oneline
$git log --oneline
Run Code Online (Sandbox Code Playgroud)

谢谢你支持我的愚蠢问题;-)

git git-pull git-fetch

16
推荐指数
2
解决办法
1万
查看次数

git pull和git reset之间有什么区别--hard origin/<branch>?

我发现后者比第一个更快,所以git fetch每当我需要将本地分支与远程同步时,我通常会这样做.有什么区别,如果有的话?

git version-control git-pull

16
推荐指数
2
解决办法
4707
查看次数