git create new branch

  1. Open the terminal or command prompt.
  2. Navigate to the directory where your Git repository is located using the cd command.
  3. Check the current branch you are on using the git branch command.
  4. Create a new branch using the git branch <branch_name> command, replacing <branch_name> with the desired name for your new branch.
  5. Switch to the newly created branch using the git checkout <branch_name> command, again replacing <branch_name> with the name of your new branch.
  6. Verify that you have switched to the new branch by running the git branch command again.
  7. Make any desired changes or additions to your code.
  8. Stage the changes using the git add <file_name> command, replacing <file_name> with the name of the file you want to stage or use git add . to stage all changes.
  9. Commit the changes to the new branch using the git commit -m "<commit_message>" command, replacing <commit_message> with a descriptive message summarizing the changes you made.
  10. Push the new branch to the remote repository using the git push origin <branch_name> command, replacing <branch_name> with the name of your new branch.
  11. Your new branch is now created and available in the remote repository. You can continue working on this branch or switch back to another branch using the git checkout <branch_name> command.