我对git有个困惑的问题
在main/development上,我有一个文件,该文件对UsersTable.tsx进行了最新的更改。
在我的工作分支chore/add-linting上,我提前提交了几个,但是我想从main/development中提取最新的UsersTable.tsx代码。
我表演了:
$ 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。
发布于 2021-12-24 00:00:33
每当需要还原一个文件时,可以考虑使用命令git restore而不是old and confusing git checkout。
就你而言:
git fetch
git restore -SW -s origin/main/development -- path/to/UsersTable.tsx这样,您就不会拉,这意味着不要将origin/main/development合并到chore/add-linting,因此不会有任何合并冲突给经理。
您只需从另一个分支的版本中还原一个文件内容。
https://stackoverflow.com/questions/70468422
复制相似问题