簡體   English   中英

如何用master更新本地倉庫?

[英]How to update local repo with master?

我習慣使用SVN,最近才切換到GitHub。

我正在嘗試更新GitHub倉庫中的一些文件,但我收到此消息:

To https://github.com/.../
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/.../'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我已經嘗試過像git fetch origingit pull這樣的命令,但這些都沒有讓我當前的分支沒有落后。

在SVN我只是做svn update然后提交我的更改。

我也嘗試過git pull origin ,但是我收到了一條奇怪的文本消息,我不知道如何與它進行交互: 使用Github存儲庫中的更改來更新本地存儲庫

  1. 使用以下命令檢查當前分支:

    git branch

    它將顯示您當前的分支名稱,並在名稱旁邊加上星號(*)。

  2. 然后使用遠程分支更新本地分支:

    git pull origin branchname (這是帶星號的分支名稱)

  3. 現在,如果已使用以下命令提交了本地更改,則可以將代碼推送到遠程存儲庫:

    git push origin branchname

如果你還沒有提交,首先做一個提交然后做一個git pull and push

當你拉動時,git打開編輯器是正常的。 這是因為您正在合並從遠程到本地分支的更改

拉動時,git會檢測是否需要將本地分支與遠程分支合並。 如果需要合並,它將執行此操作並為您提供為合並提交編寫自定義消息的機會。 此時,您可以選擇關閉編輯器,git將完成該過程。

基本上,你所要做的就是關閉編輯器 ,你就完成了。

基本上,git正在執行以下操作:

#Download all the commits from the remote
git fetch origin

# Merge in the commits from the remote to your local branch
# If anything needs merging, this will open a text editor
git merge origin/master master

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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