Reputation: 51
I create a test
branch from main
branch and start working on it,but then my team push the changes to mainline of the package.So How can I update the main
branch with the new changes that is push by my teammate, then How can I also update my test
branch with those changes.
Upvotes: 0
Views: 7949
Reputation: 94492
In your setup main
is a non-current branch. (Unlike other answers) There is a simple way to update a non-current branch without switching to it:
git fetch origin main:main
After that merge main
into the current test
using git merge main
. Or rebase test
on top of the updated main
:
git rebase main test
If you prefer merge you can do everything in one command:
git pull origin main:main
This command does git fetch origin main:main
and then git merge main
at once.
With rebase there are two commands:
git fetch origin main:main
git rebase main test
Most probably they can be combined in one command to fetch, update and rebase:
git pull --rebase origin main:main
Upvotes: 5
Reputation: 1382
git add -A
git commit -m "Some clear commit message"
main
branchgit checkout main
git pull origin main
test
branch and merge those changes with the main
branchgit checkout test
git merge main
Upvotes: 3
Reputation: 2112
You need to back-merge main branch again after updating it on your local:
git checkout main
git pull origin main
git checkout test
git merge main
git push
Upvotes: 2