繁体   English   中英

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

[英]git pull changes from remote repo keeping the changes in local file

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

不必提交或创建新分支,只需确保(如我在此处所述 )具有:

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

从那里,任何git pull都会自动:

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

另一种方法,我在这里详细介绍

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM