【问题标题】:git pull changes from remote repo keeping the changes in local filegit pull changes from remote repo 将更改保存在本地文件中
【发布时间】:2019-02-02 08:16:21
【问题描述】:

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

【问题讨论】:

标签: windows git bitbucket


【解决方案1】:

与其提交或创建一个新分支,不如像我 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 sould 保持不变。

【讨论】:

    猜你喜欢
    • 2012-05-11
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-10
    • 2013-08-31
    • 2016-12-11
    • 2013-11-06
    相关资源
    最近更新 更多