question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot fetch branch from remote.

See original GitHub issue

Description

I’ve reported this before, and it still is a problem. If I have branches on the origin that do not exist on my computer, I can’t find a way of adding these branches to my local repository without having to move to the command line. Which is something I don’t mind, but like to avoid anyway as our master students have the tendency to screw up royally when they touch the command line.

Version

GitHub Desktop version: 0.8.0

OS version: Windows 10

Steps to Reproduce

  1. Create a new branch locally
  2. Click on “Publish”
  3. Delete branch locally but not on the remote
  4. click “Fetch origin”
  5. click “Repository > Pull”
  6. close and open Github desktop again
  7. Repeat to check whether it will work this time
  8. Give up on Github desktop and go to command line
  9. git checkout --track origin/TheBranch
  10. pass computers of 2 colleagues and 3 students to check whether they found the command line and did this correctly
  11. realize one of them didn’t
  12. spend the next 15 minutes restoring what they broke
  13. report yet again and hope that this time a developer will be as kind as to implement something that avoids this ongoing frustration.

Expected behavior: I expected that fetch origin would also fetch branches on the remote and create them locally if they didn’t exist. Because one time in history, Github Desktop actually worked like that

Actual behavior: command line. Command line happened.

Reproduces how often: 100%

Logs

Additional Information

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
shiftkeycommented, Aug 24, 2017

@JoFAM @iAmWillShepherd

As shown, the new_branch is indeed on the origin, but is not added to the local repository, whereas this used to be the case when we first started using Github Desktop (probably almost 2 years ago).

The classic apps (both on macOS and Windows) do not distinguish between remote and local branches in the branch selector.

EDIT: I should make this clear here - the classic apps would remove remote information in the branch list to give the illusion the branch was created locally. The underlying Git behaviour is the same as what we’re doing in the Electron app - it’s just a visual change.

While this might make sense for common scenarios, it falls over in other places:

  • what if you have multiple remotes that all have the same branch?
  • what if your local branch that clashes with the remote branch name, but is meant to be separate?

With the Electron version, we wanted to make this relationship more clear by:

  • including the remote name for remote branches when switching branches
  • including the remote name in the push/pull/fetch button, which sits alongside the branch information

This also doesn’t include new behaviour in Git itself when checking out an unknown branch - if the name of the branch matches a remote branch, Git will create a local branch and set the tracking info automatically.

Anyway, I think we’re all on the same page now so I’m going to close this out. Let me know if you have any other questions about this.

1reaction
shiftkeycommented, Nov 20, 2018

@krpkpraveen we favour having one local repository for each remote repository, and we don’t support passing --single-branch --branch [branch] when cloning in the app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

fetch in git doesn't get all branches
The problem can be seen when checking the remote.origin.fetch setting (The lines starting with $ are bash prompts with the commands I typed....
Read more >
Git Fetch Doesn't Fetch All Branches - Randula Koralage
Even though you have pushed changes to your remote repository regarding other branches, the git fetch command doesn't update them locally.
Read more >
Why Can't Git Fetch Remote Branches Other Than Master?
Last week I came into a problem with Git, that I can't fetch the remote branch that I just pushed to. It was...
Read more >
Git Fetch | Atlassian Git Tutorial
To view your remote branches, simply pass the -r flag to the git branch command. You can inspect remote branches with the usual...
Read more >
Workarounds to Git worktree using bare repository and cannot ...
That basically means that when you try to git fetch from your remote (e.g origin ), the remote branches are not downloaded. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found