I am fairly new to using GIT. I am stuck in a problem while am working on a project. I will try to make the sequence simple to understand:
1 - A commits the code on GIT repo.
2 - A Makes some changes after commit. Does not commit them.
3 - B makes some changes and commits the code.
Now the thing is I am A and I don't want to lose the uncommitted changes that are on my local machine. Is there a way I can merge the project on GIT and the project on my local machine so that I don't lose any changes.
Any help will be appreciated. Thank you.
P.S: I am using GitHub Desktop app on Mac.
Suppose you have 3 branches, branch A, branch B, branch develop or master (whatever)
You can do this:
In branch A:
git stash -> this will save your uncommitted work
In branch B: commit and merge everything in the develop or master
In branch A: update your local repo with the remote,
git fetch and then rebase your branch
git rebase -p origin/develop
after rebase, in branch A,
git stash pop -> this will put your code again
to learn more about git stash, read this documentation
if you are using the same branch but in different computers, do the same, but instead of fetch and rebase, just
git pull and then
git stash pop