Get Off My Lawn
Get Off My Lawn

Reputation: 36331

Git track a remote branch using netbeans

I am using Netbeans, and there is a feature call Push to Upstream. When I click it I get this message:

No tracked remote branch specified for local master

Is there a way to track the remote branch in netbeans, or in the config file?

Here is my config file:

[core]
    repositoryformatversion = 0
    filemode = false
    logallrefupdates = true
    bare = false
[remote "master"]
    url = https://github.com/TheColorRed/JGame.git
    fetch = +refs/heads/master:refs/remotes/master/master

I don't have git installed on my computer, but Netbeans comes with a git package to do git operations. I don't really want to download git just to run one line, so is there a way in netbeans or in the config file to track a branch?

Upvotes: 9

Views: 7062

Answers (6)

Joshua Burns
Joshua Burns

Reputation: 8572

We keep encountering this problem and it's enough to make you mad. I've had to re-clone the repo several dozzen times by now.

Thanks to @Damian for their solution. I was a little lost in their answer, so after figuring it out thought I'd share how we were able to solve this:

  • In Netbeans, under the top menu, click Team > Repository > Repository Browser
  • Under the repository causing you problem, expand Branches > Local
  • Find the branch w/ a bolded name (that's your active branch) - Ours was called "(no branch)"
  • Right-click on the branch, and click Set Tracked Branch
  • Select the branch you want - In our case, it's called "origin/master".

Upvotes: 4

Imaskar
Imaskar

Reputation: 2949

Your local branch doesn't track remote branch. You can bind them in command line

git branch --set-upstream-to origin/master master

Or in GUI:

  1. Open Git Repository Browser
  2. Select your project -> Braches -> Local -> master (or whatever branch you want)
  3. Right click, Setup Tracked Branch

Upvotes: 0

Damian
Damian

Reputation: 41

Or you could just go to Team > Repository > Repository Browser; in the window that opens find your local branch, right-click it and select Setup Tracked Branch

Upvotes: 0

J.Steve
J.Steve

Reputation: 7319

This issue can now be solved entirely within the NetBeans interface. First, right click on the project and select Git > Branch/Tag > Switch to Branch...

Then select the desired branch (e.g. "origin/master"), and select Checkout as New Branch.

This will create a local copy of that branch, so assuming you checked out the master branch, you will now see master in addition to origin/master.

Upvotes: 0

Manuel
Manuel

Reputation: 443

Maybe my solution for this problem seems to be too easy, but I had the same error and instead of using Push to Upstream you just have to use Push for your first commit. Afterwards you can select your remote repository/branch in Netbeans.

Upvotes: 5

VonC
VonC

Reputation: 1326006

I don't have git installed on my computer

Yet, that remains the safest solution: simply unzip the archive msysgit (it you are on windows), and do a:

git branch -u master origin/master

Even other users came to the same conclusion.

Upvotes: 3

Related Questions