juan
juan

Reputation: 47

Does git switch pull all the changes

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?

Upvotes: 0

Views: 48

Answers (1)

Maik Lowrey
Maik Lowrey

Reputation: 17586

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.

Upvotes: 1

Related Questions