John Zumbrum
John Zumbrum

Reputation: 2856

Git Repo Setup work locally on branches

I have a repo setup, and am just learning about how branches work. Right now I have two branches on the remote repo: master dev

It's a little bit confusing to have the same word checkout between git and svn, since in svn it means pull all the files, but in git it only means switch where the commits will go.

I tried to git clone before I created the dev branch, but when I tried to push from my local machine it gave me a message saying it wouldn't do it due to the index and tree getting messed up if I did it.

I want to work on dev on my local machine, and possibly diff and compare that to the master branch. git clone didn't pull down the dev branch, only the master one. How should I go about doing this?

Upvotes: 0

Views: 111

Answers (2)

ryanzec
ryanzec

Reputation: 28040

You only need one clone of the repo to do what you are looking for. While you are working in the dev branch you can compare your changes with any other branch. For example to show a simple list of changes between dev and master you could do while in the dev branch:

git diff --stat master

If you want to see the actual changes between the two you can do:

git diff master

A lot of the commands will allow you to pass in branch names to do this type of functionality.

Upvotes: 1

Romain
Romain

Reputation: 12819

Actually, git clone did fetch the master branch and check it out. You can now checkout the dev branch using git checkout --track -b dev origin/dev (checkout the branch dev from the remote origin, and create a new (local) branch called dev that tracks it).

Upvotes: 1

Related Questions