This content originally appeared on DEV Community and was authored by Ruben Alvarado
If you want to add a new feature to an app you have cloned. You can create a new branch for that feature following these git commands.
git switch -c <branch-name> // creates the branch
git add <file-or-folder> // or use '.' to stage all changes
git commit -m "<commit-message>"
git push --set-upstream origin <branch-name>
You can also simply try git push
, in that case you will get a warning that the branch doesn't exist in remote yet and you receive a suggestion using the --set-upstream
parameter. Instead of memorizing the last command with the parameter you can copy and paste the command that the terminal suggests.
And that it. Use this snippet to preserve working code in master and your new code in your feature or bug fix branch.
🤓Happy coding😎
This content originally appeared on DEV Community and was authored by Ruben Alvarado

Ruben Alvarado | Sciencx (2025-10-08T18:35:59+00:00) Set New Branch in Git. Retrieved from https://www.scien.cx/2025/10/08/set-new-branch-in-git/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.