Jake
Jake

Reputation: 1370

How to pull/override local branch from updates from a different local branch?

So we have master that I do not touch and I'm currently working on feature/project.

I've been doing tons of work on feature/project and then had someone else do a couple things while I was out of office.

His code is the most up to date and it's up on BitBucket.

How do I pull his code and replace my local branch?

EDIT: I did try doing:

  1. git reset --hard feature/project to no avail
  2. git fetch, git reset --hard origin/feature/project to no avail
  3. git fetch origin, git reset --hard origin/feature/project, git clean -f -d to no avail

Upvotes: 1

Views: 86

Answers (1)

ElpieKay
ElpieKay

Reputation: 30868

git checkout master
git fetch <url> <his-branch>
git reset FETCH_HEAD --hard

url is the link to the BitBucket repository. his-branch is the branch where his code is. The commands make your local master point to his latest commit. If you'd like to update the master of your own remote repository, you need git push origin -f master. But doing so, some commits of your local master would get lost. If you'd like to keep them, run git merge FETCH_HEAD instead of git reset FETCH_HEAD --hard.

Upvotes: 2

Related Questions