Reputation: 19194
I'm using Git in Azure DevOps
I have cloned code from main to a local repo
I've made a bunch of changes in my local repo on the main branch
I need to commit these changes, but they need to end up in a new branch (local and remote)
the main branch can't be committed to directly in remote
What's the correct order to do this? I've been burnt many times by Git so I want to check with the experts before I do anything
Happy to do this all on Git command line
I'm concerned that if I commit to local main then make a local branch, when I try to push that branch back to remote, the original "main" branches won't match and it won't let me push to remote
I'm considering the brute force approach of
But maybe there is a better way.
Upvotes: 0
Views: 121
Reputation: 48
Run
git branch 'name_of_new_branch'
to create the new branch locally.
Then run
git checkout 'name_of_new_branch'
to enter the new branch.
Thereafter, run
git add . && git commit -m 'message_of_your_commit'
to commit changes locally
Then finally run
git push origin 'name_of_your_branch'
to push changes to remote branch
Upvotes: 1