Git Octo Cat

Git Branchs Management

Git is a powerful tool that can help to manage code. But sometimes we don’t know or we are scared about the features aren’t know. At least is our code and don’t want to lose any line of them.

Following the previous git post: Basic Git commands , we talk about branch.

Branch is powerful feature of git. If like we copy all code to a new directory and begin work there. But the main difference is that git knows how to join or merge this two directories without broke or lose any line of code and all in the same directory 😉

Then, we want to show how to manage branches and easiest that is.

First of all, we need to make a dir and init a new repository:

Now it’s time to create some code:

It’s time to see branches and create new ones:

Now we have two branches. Made some changes to hello.php, and test what happened:

Time to see differences:

We are in master and time to merge branches, now we say: merge second into master:

Merge two branches we don’t need the second branch, time to remove:

This kind of work with git give us the opportunity to work in different code branch with different features, it’s like work in different directories without worry about mix code later.

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *