Is it possible to merge/rebase remote tracking branch in git (local)?
I know it can be modified by git pull. But can we modify the remote tracking branch by any other git commands (locally)?
. just wondering how push will modify remote tracking branch ? (when we push our local branch to hosting site, automatically in the background, git merge runs?
There is no merge happening on the remote side:
push --force
)It is common to use a remote tracking branch to rebase a local branch on top of:
git switch my-feature-branch
git fetch
git rebase origin/main
git push --force
That way, when you do a PR (Pull Request), requesting your remote feature branch to be merged to the remote main branch, said request will be trivial to solve (since your feature branch will just add new commits on top of the remote main
).
The remote tracking branch origin/main
was modified by git fetch
(using a default refspec +refs/heads/*:refs/remotes/origin/*
)