簡體   English   中英

將我的 repo 分叉與原始 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

但除了一般情況外,我還有幾個問題。

  1. 當我執行git push時,為什么我不必指定要推送的遙控器? 還是我?
  2. 另外,我如何從upstream獲取特定的提交 ID,而不是fetch upstream時得到的最新提交?
  1. git push無需進一步推送 arguments 將使用分支的上游來確定推送的位置。 如果您在分支上,則git status將顯示此分支的當前上游(如果有)。

    您可以git branch --unset-upstreamgit --set-upstream=newupstream/example

    如果您想將當前簽出的分支推送到特定位置,例如上游,您可以執行git push upstream master

  2. 指定要獲取的提交:例如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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM