git commit to branch code example
Example 1: git command to create a branch
//Create a New Branch
git checkout -b [name_of_your_new_branch]
//First Push
git push --set-upstream origin [name_of_your_new_branch]
Example 2: git create new branch
// create and checkout new branch in one line
git checkout -b new_branch
Example 3: commit to a new branch
git checkout -b your-new-branch
git add
git commit -m
First, checkout your new branch.
Then add all the files you want to commit to staging.
Lastly, commit all the files you just added.
You might want to do a git push origin your-new-branch afterward so your changes show up on the remote.
Example 4: merge git branch
1. //pull the latest changes of current development branch if any
git pull (current development branch)
2. //switch to master branch
git checkout master
3. //pull all the changes if any
git pull
4. //Now merge development into master
git merge development
5. //push the master branch
git push origin master
Example 5: git merge branch
//this is for merging into a local branch//
// checkout the branch to merge INTO
git checkout master
// merge local feature branch into master branch
git merge feature_branch_name
Example 6: how to commit a branch in git
git commit -m "added my github name"