How to Merge Branch to Master Branch using Git Command?
Do you have question how to merge branch to master github command line? than i am here for help to git merge branch to master. i will guide you step by step how to merge branch in git. i written all command for github merge branch into master branch.
Almost developer knows how to pull, how to commit, how to add and how push. no some developer that don't know how to create branch and merge branch with master.
Now in our field we are using git on our all laravel project as we can say. if you are working more than 3 developer than almost create developer wise own branch. developer work on his own branch. but than at last they merge in master branch. So how they are merge using command line i will show you step by step.
You have to simple follow this tutorial, i written step by step command for merge branch and how it works.
You can merge branch using following command:
git merge dev
git push origin master
Step by Step Explanation of Create and Merge Branch with Github
I already created my demo repository on my github account. You can also create your own. i will clone my repo by using following command:
git clone git@github.com:savanihd/Demo-Git.git
After clone i will go on that project.
cd Demo-Git/
Now i will check how much branch in my repo now. right now i have only master. you can see both screen.
git branch
* master
Now create master.html file in your master branch as like bellow:
master.html
<!DOCTYPE html>
<html>
<head>
<title>Master File</title>
</head>
<body>
</body>
</html>
Now you can push this file on your master branch using following command:
git add .
git commit -m "master file created"
git push origin master
Now i will create new branch for development using following command:
git branch dev
Check branch is created or not:
git branch
dev
* master
We created dev branch but still we are in master branch. So now we have to checkout in dev branch using following command:
git checkout dev
git branch
* dev
master
Now we are in dev branch. So we will create dev.html file on dev branch. so let's create with following code.
dev.html
<!DOCTYPE html>
<html>
<head>
<title>Dev File</title>
</head>
<body>
</body>
</html>
Now you can push this file on your dev branch using following command:
git add .
git commit -m "created dev file"
git push origin dev
Now we merge dev branch to master branch.
Let's run following command:
git checkout master
git merge dev
git push origin master
Now you can see on github repository and check it.
master branch merge with dev.
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Remove File from Git Commit Before Push?
- How to Delete a Branch using Git Command?
- How to Rename Branch Name in Git Command?
- How to Switch Branch using Git Command?
- Github - How to Create New Branch using Git Command?
- How to Ignore Wildcard Files Name in Git using Gitignore?
- Laravel 9 Socialite Login with Github Account Example
- Git Command to Ignore File Permission Changes
- How to Add Git Add Remote Origin on Bitbucket Repository?
- Git - How to Find a Deleted File in Commit History?
- How to Configure Git Username and Email?
- How to Git Force Pull from Remote Branch?
- Git Remove Last Commit from Local Example
- How to remove current changes from local system in Git ?