Does git switch pull all the changes

53 Views Asked by At

When one does git switch branch. Does all the latest changes and files from the remote repository get copied to the local branch? Is it like a replica of remote is created on local and the local and remote both are linked?

1

There are 1 best solutions below

0
On

TL;DR

No!

Switch Branch

  1. all files that have been changed in your initial branch will be taken to the new branch.
  2. all files that you have already committed in your original branch will not be taken along. However, you can then pull in the commit in the source branch.

As long as you make your commits and branch changes locally, your remote remains unaffected. Only with a git push are your "committed" changes transferred to the remote. Before that, however, you must first perform a git merge in your source branch so that the changes take effect.