[英]I want to fork a repo, add a feature and keep syncing with original repo
[英]Syncing my fork of repo with original repo
我看到很多关于这个的帖子,我知道一般的答案,从我的 fork 的本地 repo 执行这个:
git remote add upstream https://github.com/abcd/efgh.git
git fetch upstream
git merge upstream/master
(resolve merge conflicts)
git commit -m "my message"
git push
但除了一般情况外,我还有几个问题。
git push
时,为什么我不必指定要推送的遥控器? 还是我?upstream
获取特定的提交 ID,而不是fetch upstream
时得到的最新提交? git push
无需进一步推送 arguments 将使用分支的上游来确定推送的位置。 如果您在分支上,则git status
将显示此分支的当前上游(如果有)。
您可以git branch --unset-upstream
或git --set-upstream=newupstream/example
如果您想将当前签出的分支推送到特定位置,例如上游,您可以执行git push upstream master
指定要获取的提交:例如git fetch upstream 61586219a7450af5a72f857db62d9a89ad9cc38f
可以使用FETCH_HEAD
在 git 命令中访问获取的提交。 例如git log FETCH_HEAD
。
注意:并非所有存储库都允许获取任意提交。 例如,他们可能只允许获取命名分支和拉取请求( github )。
我所做的是:
git remote add upstream https://github.com/abcd/efgh.git
git fetch upstream
git checkout 1q2w3e4r5t -b giveItABranchName
git checkout main
git merge giveItABranchName
(resolve merge conflicts)
git commit -m "my message"
git push
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.