我有一個令人困惑的問題 git
在main/development我有一個包含最新更改的檔案UsersTable.tsx
在我的作業分支上,chore/add-linting我提前了一些提交,但我想UsersTable.tsx從main/development.
我表現:
$ git pull origin main/development
# oh no, I have a couple merge conflicts
# I want this file to be whatever is exactly on `main/development`
$ git checkout main/development path/to/UsersTable.tsx
Updated 1 path from f59fed63
但是,該檔案不是main/development!它為我檢查的版本仍然落后main/development并且有舊代碼。
這里發生了什么?我做到了git fetch,并且git pull.
uj5u.com熱心網友回復:
每當您需要恢復一個檔案時,您可能會考慮使用該命令git restore而不是舊的和令人困惑的git checkout.
在你的情況下:
git fetch
git restore -SW -s origin/main/development -- path/to/UsersTable.tsx
這樣,您不會拉動,這意味著不會合并origin/main/development到chore/add-linting,因此您不會與經理發生任何合并沖突。
您只需從另一個分支的版本中恢復一個檔案內容。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/391817.html
標籤:混帐 版本控制 分支 git-checkout
