我從空目錄開始:
git clone --no-checkout <repository> <directory>
我有以下引數:
<remote>- 拉取請求的分支(不是 HEAD),例如integration<filepath>- 要更新的檔案路徑,例如version.txt
下一步應該是什么?
更新:
最后,以下對我有用:
# clone and create local branch named <remote> from <remote>
git clone --no-checkout --branch <remote> <repository> <directory>
cd <directory>
# checkout only one file
git checkout <remote> -- <filepath>
edit <filepath>
# commit only one file
git commit -m <message> -- <filepath>
# push local branch to a new remote branch
git push origin <remote>:refs/heads/<remote>-edit
但是,此腳本僅適用于每個存盤庫的一個分支。如果應該以這種方式更新多個分支,git reset則仍然需要一些。
uj5u.com熱心網友回復:
你的問題沒有明確,所以我假設你正在使用 GitHub 上的存盤庫。
如果您試圖避免檢出大型存盤庫中的所有檔案,則通過 github web ui 編輯單個檔案可能是最簡單的,因為這樣您不需要將存盤庫克隆到本地檔案系統。
如果這不是一個選項,那么也許這樣的事情會起作用:
Fork GitHub 上的存盤庫
克隆存盤庫的分支:
git clone --no-checkout <repository> <directory>切換到作業目錄:
cd <directory>重置存盤庫狀態(因為 ,存盤庫中的
--no-checkout所有檔案最初都將暫存以進行洗掉):git reset HEAD為您的作業創建一個新分支:
git checkout -b my-new-feature查看要修改的檔案:
git checkout HEAD src/main.c進行更改:
vim src/main.c為提交暫存這些更改:
git add src/main.c提交更改:
git commit -m "Add awesome new feature"將更改推送到遠程存盤庫:
git push -u origin HEAD從該分支向目標分支發出拉取請求。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/405530.html
標籤:
