arialdomartini / oh-my-git

An opinionated git prompt for bash and zsh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tracking remote isn't shown when push URL is different

Sgiath opened this issue · comments

Git let us set up different URL address for pushing

$ git remote add origin https://github.com/arialdomartini/oh-my-git.git
$ git remote set-url --push origin https://github.com/Sgiath/oh-my-git.git

this is very useful when you work with your fork where you want to push but you want pull just from main repo.
Config file after this look like this:

[remote "origin"]
    url = https://github.com/arialdomartini/oh-my-git.git
    fetch = +refs/heads/master:refs/remotes/origin/master
    pushurl = https://github.com/Sgiath/oh-my-git.git

But when I create new feature branch and push it to my repo:

$ git checkout -b feature/my-awsome-feature
$ git push --set-upstream origin feature/my-awsome-feature

oh-my-git still shows it as local branch.
But now I can easily push this branch like this:

$ git push

and it's correctly pushed to my repo Sgiath / oh-my-git.
Config for this branch is following:

[branch "feature/my-awsome-feature"]
    remote = origin
    merge = refs/heads/feature/my-awsome-feature

Can you please fix this use case?

I'm sorry this isn't issue with different fetch and push URL.

It was caused because I used --single-branch for cloning so in config for remote origin was:
fetch = +refs/heads/master:refs/remotes/origin/master
That means that git is watching just for master branch and not for others. There should be
fetch = +refs/heads/*:refs/remotes/origin/*

So no bug here 😃