3

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 future 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?

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

If you really want it to be called foo then you could make an alias for pushing to foo. Look for alias.* on kernel.org/pub/software/scm/git/docs/git-config.html
1

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

1 Comment

You can use 'git remote rename <old_name> <new_name>' To erase the old origin and make foo the new one 'git remote rm origin' 'git remote rename foo origin'
0

You need to set the remote origin url:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.