1

I have made changes in my local repo, when I try to pull from master I get error like please commit your changes or else it would be lost.

Whats the ideal process in this case?

I saw something like --rebase.
What I am doing right now is taking a backup of my files and then updating and merging manually.

Is there a better way to this?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Hacker
  • 7,798
  • 19
  • 84
  • 154

2 Answers2

0

You can commit your changes and then take a pull from master. This way, you will have all the changes you made and all the changes in master intact.

Priyansh Goel
  • 2,660
  • 1
  • 13
  • 37
  • So, git pull will automatically merge the code if there is no conflict. Elase, just remove the conflicts and do a commit. – Priyansh Goel Sep 27 '16 at 06:31
0

What I do now is take backup of my file and then take update and manually merge.
Is there a better way to this?

After "Can “git pull” automatically stash and pop pending changes?", you can simply do git pull (only for Git 2.9+, June 2016):

Add the following config:

git config pull.rebase true
git config rebase.autoStash true

That way, only a git pull is needed.

git stash will backup your files (local modifications).
Your local commits will be rebased on top of the upstream branches.
And your local changes (not yet committed) will be restored.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250