簡體   English   中英

從octopress分支上的意外git pull中恢復

[英]Recovering from accidental git pull on octopress branches

從bash遷移到zsh時,這將gl的別名從'git log'更改為'git pull'。 然后,我在octopress博客中運行該程序,首先在“ master”分支上,然后在“ source”分支上

大錯。 在Github上,origin / master分支用於部署,而origin / source是您的博客資源。

在“ master”分支上,我似乎獲取了Octopress的所有最新提交。 我猜我不需要擔心這一點,因為我使用了source分支進行生成。 (對?)

接下來,在拉入我的源分支時:

  1. 在Vim中按:cq中止了合並提交。
  2. 然后,我注意到我將_deploy目錄中的所有內容都添加到了頂層目錄中。

我考慮過用git clean刪除多余的目錄,但這似乎是要刪除被忽略的文件/目錄(使用dry-run選項!)。

因此,手動rm -rf在git狀態下顯示為未跟蹤的目錄/文件列表。

所以我的git狀態現在看起來很干凈。 如果列出遙控器,則會得到以下信息:

$ git remote show origin
* remote origin
  Fetch URL: git@github.com:justin808/justin808.github.io.git
  Push  URL: git@github.com:justin808/justin808.github.io.git
  HEAD branch: master
  Remote branches:
    flattr tracked
    master tracked
    source tracked
  Local branch configured for 'git pull':
    source merges with remote master
  Local refs configured for 'git push':
    flattr pushes to flattr (up to date)
    master pushes to master (local out of date)
    source pushes to source (up to date)

我還有什么需要檢查的嗎?

有什么辦法可以使我變得更加白痴,以至於我不能在此設置中不小心git git pull?

更新

  1. 當我使用magit時,我看到大量未拉出和未按下的提交
  2. 我的git配置有這個:
 [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = false [remote "octopress"] url = git://github.com/imathis/octopress.git fetch = +refs/heads/*:refs/remotes/octopress/* [branch "source"] remote = origin merge = refs/heads/master [remote "origin"] url = git@github.com:justin808/justin808.github.io.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = octopress merge = refs/heads/master 

我猜測問題是我的源分支不應該具有

merge = refs/heads/master

也許應該是:

merge = refs/heads/source

或者,也許我應該只刪除該行? 實際上不,因為那樣我在zsh提示符下無法獲取有關分支是否位於github后面的正確信息。

如果需要更改“源”的上游分支,可以執行以下操作:

git branch --set-upstream-to source origin/source
# or
git branch -u source origin/source

(更多信息在“ 如何更改git分支正在跟蹤的遠程? ”中)

暫無
暫無

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

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