To Switch Branch on Git , we can use git checkout or git switch. Personally , I think the easiest way is to use git checkout command . This command enable us to switch a branch if it exist or to create a new branch if we add -b .

Solution 1

$ git checkout <existing_branch>

$ git checkout -b <new_branch>

To use the git switch command, we have to replace -b with -c to create a new branch. Lets see the next example.

Solution 2

$ git switch <existing_branch>

$ git switch -c <non_existing_branch>

Git provides many commands to manage your projects , as a developer , read this tutorial to know The GIT commands you absolutely must know !!


Also learn how to undo the recent local commits in Git ?

Tagged:

Commentaires

  1. Pingback: (SOLVED) How to change the commit message after a push ? » JavaTuto

Laisser un commentaire