Home > OS >  How to pull from a master branch into a feature branch without losing changes in the feature branch
How to pull from a master branch into a feature branch without losing changes in the feature branch

Time:08-03

I'm a newbie to Git and need some advice on doing this. I'm developing on a feature branch and making changes to my local repository.

However, I'd like to pull changes from the master branch often to make sure that my feature branch is updated and I'm making changes on the latest version.

Can someone please guide me if this can be done while retaining changes in the local repository?

Is there a manual way to resolve conflicts or any other suggested approach?

Thanks in advance. All the inputs are highly appreciated.

CodePudding user response:

you should do the following:

git stash save "Local uncommitted changes"
git pull
git stash pop # Retrieve local uncommited changes

Rembember that the git stash pop may generate conflicts you will have to solve.

CodePudding user response:

If the branch you are currently working on is based on top of an older master version, you need to either rebase your branch or merge master onto your branch.

Commit changes on your current branch then:

git checkout master
git pull
git checkout <your_branch>
git rebase master

You might need to solve conflicts.

  • Related