git pull from remote repo的更改将更改保存在本地文件中

时间:2019-02-02 08:16:22

标签: windows git bitbucket

我在本地项目目录中有一个修改后的文件htmlpage.html,我想从 bitbucket 上的远程分支拉出对该文件的更改,而不会影响我的本地文件更改

1 个答案:

答案 0 :(得分:0)

就像我explain here一样,只需提交以下内容,即可提交或创建新分支:

git config --global pull.rebase true
git config --global rebase.autoStash true

从那里,任何git pull将自动:

  • 存储本地更改
  • 通过在更新(获取)的远程分支(pull --rebase)上重播本地提交来更新当前分支
  • 重新将您的藏匿地址更改为htmlpage.html

另一种方法,我detailed here

git update-index --skip-worktree -- htmlpage.html
# to cancel it:
git update-index --no-skip-worktree -- htmlpage.html

在测试git pull之前,请先保存文件副本:htmlpage.html保持不变。