Git Branches
Create a new git repository (if you don't already have one)
$ git init
Check existing branches
$ git branch
=> *master
Create and switch to a new brach
$ git checkout -b newbranch
You have created and switched to the branch newbranch.
Let's mess around a little, create a new file under this branch (unix):
$ touch file.txt
Add the file.txt to git
$ git add .
Commit your changes
$ git commit -m "file.txt added"
Going back to the master branch
$ git checkout master
Notice that file.txt don't exist under the master branch. You need to merge the newbranch with the master branch to keep everything updated.
$ git merge newbranch
Now your master brach have access to file.txt. Check your logs.
$ git log
Happy Hacking!
Written by Mariz Melo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#