Pushing new branches does not set up tracking branch completely
See original GitHub issueWhen you push a local branch that does not exist on the remote (using the refspec overload), libgit2sharp automatically creates a tracking branch, but it does not set up the config for the local branch
i.e. the following config entries are missing:
branch.(branch_name).remote
branch.(branch_name).merge
Currently, I push a new branch like as follows:
string refspec = string.Format("{0}:{1}",
currentBranch.CanonicalName, currentBranch.CanonicalName);
repo.Network.Push(remote, refspec, handler, credentials);
repo.Branches.Update(repo.Head, delegate(BranchUpdater updater)
{
updater.Remote = remote.Name;
updater.UpstreamBranch = repo.Head.CanonicalName;
});
I feel like this should be simplified. Either by doing the BranchUpdater
stuff in Push()
, or by extending the Push(Branch, ...)
overload to let it accept non-tracking branches and do the whole process.
I also did not find a test fixture covering that feature, so the intended behaviour should at least be specified.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:2
- Comments:9 (7 by maintainers)
Top Results From Across the Web
There is no tracking information for the current branch
This happens due to current branch has no tracking on the branch on the remote. so you can do it with 2 ways....
Read more >Fix Git's "fatal: no upstream branch" error quickly example
The simple solution to the current problem is easily solved by issuing the following Git push upstream command:
Read more >How To Set Upstream Branch on Git
Complete step-by-step tutorial on how to set upstream branches (remote tracking branches) on Git easily using branch commands.
Read more >Git - Remote Branches
Remote-tracking branches are references to the state of remote branches. They're local references that you can't move; Git moves them for you whenever...
Read more >Git Push to Remote Branch – How to Push a Local ...
The basic command for pushing a local branch to a remote repository is git push. This command has a variety of options and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @wilkovanderveen,
There is a workaround how to solve this.
`
I know this topic is from 9 years ago. But is this fixed?