Search code examples
gitgit-pushgit-remote

performing git push with repo URL pre set


every time I have to push my branch to remote on GitHub I have to run the following command,

git push --set-upstream sensorAtHome WIP

however at office I just go ahead and push to our company cgit server.

so what is different and what do I need to do, locally for my GitHub project I have a already done this:

git remote add <name> <url>

I thought that was enough .

secondly what <name> refers to name of branch or name of repository?


Solution

  • Check your git branch -avv output, as well as git remote -v

    Your office branch is probably already linked to a remote tracking branch.

    See "Why do I need to explicitly push a new branch?"

    You should push once with:

    git push -u sensorAtHome WIP
    

    Then a simple git push would be enough: your local branch would know where and to which branch to push ("where" is sensorAtHome remote url, and "which branch" is sensorAtHome/WIP)