1

Solo dev who is finally decided to use git and github instead of multiple versions on my hard drive.

I have created an initial master branch that I uploaded the current state of my project to.

I am now going to add a new feature to this project and after reading around I am sure that it is good to add new features to a new branch in github.

So I created a new branch in github.

But on my local machine I already have git that pushed to the master branch on the initial commit.

So now do I have to the clone the 2nd branch from github to my local machine or do I just keep developing as usual and only switch to the 2nd branch when I am ready to push the changes to github.

It's kind of simple stuff but just confusing as what to do and how to do it.

Thanks in advance.

1
  • I suggest that you read Pro Git for a deeper understanding of how git works. Chapters 2 and 3 are pretty much all you need for day-to-day work. Commented May 22, 2019 at 22:06

1 Answer 1

1

With Git and GitHub together, there are often multiple correct ways to accomplish a task.

However, the typical way this is accomplished is to create a branch locally (let's call it 'test'), and set it to track an origin branch.

$ git checkout -b test Switched to a new branch 'test' $ git push --set-upstream origin test * [new branch] test -> test Branch 'test' set up to track remote branch 'test' from 'origin' by rebasing. 

Do your work on test, periodically pushing it to GitHub. When finished, merge the branch into master at the command line, or open a pull request on GitHub and merge it there.

You don't need to create a branch in GitHub to do work on your own local branch.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so are you saying that I didn't need to create the branch in the remote github, just do it on my local machine
@UncleVector Yes. Once you get the hang of working with branches on your local machine, then you can learn how to get branches from a remote repo, like GitHub.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.