I have a modified file htmlpage.html in my local project directory and i want pull changes for that file from remote branch on bitbucket without effecting my local file changes
Asked
Active
Viewed 35 times
1
-
Possible duplicate of [this question](https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files) – Wander3r Feb 02 '19 at 08:27
-
Possible duplicate of [How do I force "git pull" to overwrite local files?](https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files) – Manoj Choudhari Feb 02 '19 at 09:43
-
2`git commit` local changes, `git pull` – sergej Feb 02 '19 at 11:03
-
1Or if you want to track the two versions create a new branch... – Christoph Feb 02 '19 at 13:18
1 Answers
0
Instead of committing or creating a new branch, simply make sure, as I explain here, to have:
git config --global pull.rebase true
git config --global rebase.autoStash true
From there, any git pull will automatically:
- stash your local changes
- update your current branch by replaying your local commits on top of the updated (fetched) remote branch (
pull --rebase
) - re-apply your stashed changed to your
htmlpage.html
Another approach, I detailed here:
git update-index --skip-worktree -- htmlpage.html
# to cancel it:
git update-index --no-skip-worktree -- htmlpage.html
Save a copy of your file first, before testing a git pull
: htmlpage.html
snould remain unchanged.

VonC
- 1,262,500
- 529
- 4,410
- 5,250