My local repo is behind a couple of commits on a specific branch. I have a commit on my outdated local repo.
How do I update my local repo to reflect the remote repo, and then apply my commit that I have made?
My local repo is behind a couple of commits on a specific branch. I have a commit on my outdated local repo.
How do I update my local repo to reflect the remote repo, and then apply my commit that I have made?
You could try git stash
to save your local changes then git pull
. To get the latest. It should then prompt you to merge
The git rebase --onto
command was created for that very use case. First fetch your remote branch, checkout the local branch you want to apply the remote changes to and then rebase:
git fetch origin <remote branch>
git checkout localBranch
git rebase --onto origin/remoteBranch localBranch~1
Note that ~1
should be changed to the number of commits you have on your localBranch that you want to replay on top of the remoteBranch. Since you pointed out that you only have 1 commit on your localBranch, this should work.