0

I have been doing all my work on the master branch. Since I created my project and pushed it into my Github repository, I have been the only one working on it so I have had no need to fetch.

I want to work on an experimental feature, so I want to create a new branch. When I go to "Team -> Switch To -> New Branch" I see this:

What I see when branching It mentions creating a branch based on a local branch. I have read EGit Local vs. Remote repositories but to be honest I am quite confused by it. I'm not sure if I should be fetching or cloning because both are mentioned there, and even then I'm not sure how I would do it (like I said, as I am the only contributor to this project all I've had to do so far is commit and push).

And even then, I'm not sure if Rebase, Merge, None should be my pull strategy as shown in the screenshot?

I was hoping I could just create a new branch, commit and push like I normally do and then switch back to my master branch when I didn't want to work on my experimental feature. It seems like it's much more complicated than that.

I'd like to be able to do this through Eclipse so I learn how for the future, but will it be easier if I just do this on the Git command line? Thanks in advance.

Community
  • 1
  • 1
b85411
  • 9,420
  • 15
  • 65
  • 119

1 Answers1

0

It sounds like what you want is to create your (local) branch based the remote/origin master (use the drop-down list at the top) and then select Merge as your pull strategy. That way when you are working on the branch and pull, it will pull from master and merge any changes directly into the branch. It also allows you to push the branch to remote, which give you another level of safety in case your local repo gets lost or messes up somehow.

Another piece of advice I've learned the hard way: whenever I'm about to do something with git that I'm not totally confident about, I make a quick ZIP or copy of my local repo. That way it's easy to throw away whatever I did and go back to a good state. Sad that git drives us to such measures, isn't it?

E-Riz
  • 31,431
  • 9
  • 97
  • 134
  • Hi E-Riz, good point about the ZIP file! I will be doing that for sure before I try this. I did as you suggested, but the only other option in my drop down is "HEAD". I think I may need to do a Fetch (as I have never done this before) to get the remotes to appear there. Does that sound right? If so, when I fetch do I risk losing any of the work I currently have (I have committed and pushed, so there are no new edits - I am just worried if, for example, fetching could remove any files that I have git ignored?). Thanks for your help. – b85411 Feb 18 '14 at 03:10