Question

I am fairly new with Git and using Git on my windows machine through the command prompt. Currently I only have got one master branch and I want to create a new branch (current). I'm a bit confused with some of the commands.

Can someone give me some instructions to follow? I don't find git references very useful. I am not new to source control, just new to Git. Thanks.

Was it helpful?

Solution

Please read the Pro Git book.

To make a branch in the same place as you are in history:

git branch branch_name

to switch to that branch use

git checkout branch_name

you can do both of those at the same time with:

git checkout -b branch_name

to keep alternating between the last 2 branches use

git checkout -

(this is the similar to the behaviour of cd -)

Once you get better with the syntax of git, use a good branching strategy and stick with it. I use Branch per Feature.

OTHER TIPS

This book will give you good introduction. It explains the commands in very detail and some with graphs to let you know the work process of git. http://git-scm.com/book You can give create a branch with command like this:

git checkout -b branch_name

I recommend reading the git pro book - it's not a long read, and its free. It will teach you all the important concepts and would be much better than just giving you the branching syntax.

http://www.git-scm.com/book

However, to branch try:

git checkout -b <name>

Which will create a new branch and switch to it.

This tutorial is the best interactive tutorial available online if you would like to clear your concepts of git branching.

http://pcottle.github.io/learnGitBranching/index.html?demo

to create a branch

$ git checkout -b your_branch

to add to staging area and commit changes - all(shortcut)

$ git commit -a -m "your message"

to push to hithub(only if you already have a repo)

$ git push origin your_branch

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top