为什么我切换到 master 时看到另一个分支的更改?
Why do I see changes from another branch when I switch to master?
我做了 git checkout -b profile
并对该分支做了一些更改。
我不喜欢这些更改,想从 master
分支取回我的代码,而不需要从 profile
分支进行更改。
但是,当我执行 git checkout master
时,我看到了 profile
分支的更改。
有没有办法找回以前的代码?
您可以看到更改,因为更改未在 profile
分支中提交。
尝试以下命令重置您的 master
分支:
git checkout master
git pull
git reset --hard origin/master
它将使用 repo master
重置您的本地 master
分支
除上述之外,您可以通过以下命令删除不需要的更改
git checkout file1name file2name
如果要删除所有未提交的更改,可以使用
git checkout .
我做了 git checkout -b profile
并对该分支做了一些更改。
我不喜欢这些更改,想从 master
分支取回我的代码,而不需要从 profile
分支进行更改。
但是,当我执行 git checkout master
时,我看到了 profile
分支的更改。
有没有办法找回以前的代码?
您可以看到更改,因为更改未在 profile
分支中提交。
尝试以下命令重置您的 master
分支:
git checkout master
git pull
git reset --hard origin/master
它将使用 repo master
master
分支
除上述之外,您可以通过以下命令删除不需要的更改
git checkout file1name file2name
如果要删除所有未提交的更改,可以使用
git checkout .