Made git clone with repo, my branch is master . I need to switch to another branch of the remote repo, which is not locally - test-branch . If you create a branch from the master and pull it there, then conflicts arise and you need to merge it all. And I do not need to merge, you just need to switch to the remote branch without changes from the wizard.

That's when I do it.

  1. git clone remote

  2. git checkout test-branch

  3. git pull origin test-branch

My master and remote test-branch merge, which I don't need. Perhaps there is a way to switch to a remote branch without merging?

    2 answers 2

    First, you can immediately clone the desired branch.

     git clone -b <branch> <remote_repo> 

    In your case, you can create a local branch during checkout:

     git checkout -b feat_branch origin/feat_branch 

    Or, without direct switching:

     git branch feat_branch origin/feat_branch 
    • It may be worth mentioning that the git checkout command can be passed the name of a remote branch without the -b parameter, and about the mode of a disconnected headmymedia
    • Then you will still need git checkout -b new_branch . Besides, I'm not sure whether to track the parent branch) It depends on the configs. - vp_arth

    After you clone the repository, do git fetch , then git checkout test-branch