我很难理解git-fetch的细微差别.我知道做一个fetch,将远程refs提取到本地跟踪分支.
我有几个问题:
是否有可能本地跟踪分支不存在?如果是,那么它会自动创建吗?
如果我执行fetch并指定非跟踪分支作为目标,会发生什么?
git-fetch的手册页指定:
git-fetch <options> <repository> <refspec>
Run Code Online (Sandbox Code Playgroud)我如何使用refspec从远程主站获取内容到其远程跟踪分支?我相信如果我现在的HEAD在主人身上并且我跑了,这可能是可能的
git fetch origin master
但是,我可以使用<+?src:dest>refspec来实现同样的目的吗?我认为这将有助于我更好地理解这些概念.
还有一个问题:
我的.git/config文件有以下行用于获取(仅显示相关行):
fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)
有人可以解释这条线的确切含义吗?
我想知道我的本地回购是否是最新的(如果没有,理想情况下,我希望看到更改).
我怎么能检查这个而不做git fetch还是git pull?
$ git pull
remote: fatal: object 21f3981dd35fccd28febabd96f27241eea856c50 is corrupted
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: aborting due to possible repository corruption on the remote side.
fatal: protocol error: bad pack header
Run Code Online (Sandbox Code Playgroud)
任何想法为什么失败?
当我跑步时,git --bare fsck-objects --full我只看到悬挂的链接,但没有断开的链接.也git gc没有任何帮助.当我从另一个克隆中重新克隆或拉动时,我没有看到这个错误.
我之后不想丢失一些信息git pull,所以我git fetch之前做过一次.我在哪里可以阅读新的修改git fetch?我去了FETCH_HEAD文件,但没有什么比一个大数字.
有时候,尤其是 当我是唯一一个在远程存储库上工作的人时,我喜欢用git rebase -i和重写历史git push origin master -f.
如何在git pull origin master没有合并的情况下强制执行?我尝试了-f选项,但是没有用.我只想重写我本地git仓库的历史记录以匹配远程(原点)的历史记录.
有一次,我认为git fetch origin --prune删除了服务器上不再存在的本地分支.不知何故,这不是我目前的经历.
我运行了这个命令,并没有删除本地分支.目前尚未检出.我跑去git branch -vv检查这个信息,我明白了
feature/MyGreatFeature f30efc7 [origin/feature/MyGreatFeature: gone]
Run Code Online (Sandbox Code Playgroud)
所以似乎知道它已经消失了.为什么不删除我的本地分支?
运行 git version 2.7.4 (Apple Git-66)
根据文档,git pull执行git fetch然后执行git merge,但是在这种情况下执行git pull origin master应该执行git fetch origin master吗?但是,它似乎没有这样做.这是一个例子.
假设我的远程源主站(在我的情况下在GitHub上)具有以下历史:
commit 1111111 : my first commit
commit 2222222 : a commit from someone else
Run Code Online (Sandbox Code Playgroud)
我只在本地进行了第一次提交作为以下节目
git checkout master
git log --pretty=format:'%h' -n 1
1111111
git checkout origin/master
git log --pretty=format:'%h' -n 1
1111111
Run Code Online (Sandbox Code Playgroud)
从这里开始,我看看结果如下:
git checkout master
git pull origin master
git log --pretty=format:'%h' -n 1
2222222
git checkout origin/master
git log --pretty=format:'%h' -n 1
1111111
Run Code Online (Sandbox Code Playgroud)
可以看出,拉实际上确实使用来自远程源的新提交来更新我的主分支,但是我的本地origin/master仍然是它的位置.强迫我做以下事情
git fetch origin master …Run Code Online (Sandbox Code Playgroud) 我所有的Jenkins构建都在失败git fetch.
它失败了 git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git
Started by user anonymous
Building in workspace /Users/ethen/.jenkins/workspace/Build NikNik
> git rev-parse --is-inside-work-tree
Fetching changes from the remote Git repository
> git config remote.origin.url git@bitbucket.org:ethenwilson/whentoact.git
Fetching upstream changes from git@bitbucket.org:ethenwilson/whentoact.git
> git --version
using GIT_SSH to set credentials NikNik BitBucket SSH Key
> git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*
FATAL: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:622)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:854)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:879)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)
at …Run Code Online (Sandbox Code Playgroud) 我们在Windows Server 2012上的Jenkins安装上遇到了缓慢的git fetch命令.我已经尝试了这些线程中提到的所有解决方案:
Hudson git命令*令人难以置信*慢(使用PuTTY中的plink.exe并设置GIT_SSH使用它)
Jenkins挂在"从原点获取上游更改"(更改Jenkins以使用cmd\git.exe而不是bin\git.exe)
任何人都可以通过永久修复找到解决方案吗?
Jenkins的控制台输出日志:
由远程主机启动
在工作区F:\ Jenkins\jobs\xxx\workspace中构建主服务器
> git.exe rev-parse --is-inside-work-tree #timeout = 10
从远程Git存储库中获取更改
> git.exe config remote.origin.url xhttp:// scm/git/xxx #timeout = 10
从xhttp:// scm/git/xxx获取上游更改
> git.exe --version #timeout = 10
使用.gitcredentials设置凭据
> git.exe config --local credential.helper store --file = \"C:\ Users\APP_JE~1\AppData\Local\Temp\git7476037793811743133.credentials \"#timeout = 10
> git.exe -c core.askpass = true fetch --tags --progress xhttp:// scm/git/xxx + refs/heads/:refs/remotes/origin /
问题在这里:上述命令可能需要30秒到120秒.在本地开发机器上需要几秒钟.
> git.exe config --local --remove-section credential #timetime = 10
版本信息:
詹金斯:1.608(最新) …
我正在开发一个项目,每个人都将其SVN用作集中式服务器,每个人都会推动他们在该服务器上所做的更改.我想在Git本地使用,我很新git svn.我做了一个git svn clone存储库,git svn clone -r HEAD https://svn.repo/app/branch我希望通过git进行更新.
我需要一个'git pull like'命令,但要从SVN服务器repo的特定版本中提取.还有一个'fetch like'命令从SVN服务器repo的特定修订版中获取?
我的.svn克隆项目git remote中没有任何文件夹,也没有给我任何东西.但是我做了一个git config -l,我得到了SVN服务器的URL,所以不知怎的,我与SVN服务器链接.我不知道如何取或拉.
谢谢!