开发者

Assign a remote for Git Push

开发者 https://www.devze.com 2023-01-27 13:33 出处:网络
I\'ve been developing in a local repository for a while and just set up a git server. In the past, when the remote repo already exists, I can do a git clone, and then fu开发者_Python百科ture git push

I've been developing in a local repository for a while and just set up a git server.

In the past, when the remote repo already exists, I can do a git clone, and then fu开发者_Python百科ture git push just works -- it seems to be associated with the remote that git clone retrieved.

Since I want to push all my existing work to this fresh remote, I did a git remote add foo. But git push still doesn't work, I have to do a git push foo master.

How can I make foo master be the default so that git push works on it's own? And secondly, did I approach this in the right way? How would you populate a new remote repo with an existing local repo?


If you want git push to push to a remote without any additional parameters, rename that remote from foo to origin.


By default git push will try to push to a remote called origin, which is automatically created by git clone to point to the repository you cloned from. There's probably a git command to set a branch's remote, but I don't know it; you can edit .git/config manually though. Find the section for the branch you're pushing from (e.g. [branch "master"] if it's the master branch), and change remote = origin to remote = foo


You need to set the remote origin url:

git config --get remote.origin.url
git config --edit
0

精彩评论

暂无评论...
验证码 换一张
取 消