Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have it to where "git push" pushes to local repositories?

Tags:

I can do git remote add origin x@x:~/blah and git push will work. But if I create a local copy git clone ~/blah inside /var, then git remote add local /var/blah inside ~/blah, when I try git push it doesn't push the updates.

How can I make git push updates to local copies?

I have a shared library I use in a bunch of projects. I use git clone inside other folders to get a local copy of the library. When I update the main library I have to go to each local copy and type git pull to get the updates? How can I say git push to push code to all libraries?

like image 825
ForeverConfused Avatar asked Jan 14 '11 17:01

ForeverConfused


People also ask

Can git push to local repository?

The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.

How do I change where git pushes to?

Run the git remote set-url --add --push origin git-repository-name command where git-repository-name is the URL and name of the Git repository where you want to host your code. This changes the push destination of origin to that Git repository.

How do I push to local remote repository?

Push a new Git branch to a remote repo Clone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.

How does git know which repository to push to?

git directory that contains metadata about the repository. That's what Git uses to determine where to push your changes.


Video Answer


1 Answers

By default, git push pushes to origin. If you want to push to a different remote repository (on the same machine or otherwise), you need to do git push <remote-name>. Also keep in mind what mipadi says about non-bare repositories.

So in your case, after a git remote add local /var/blah, you would do git push local to push changes to the repo in /var/blah.

A little google-fu came up with this post for pushing to multiple remote repositories at once:

http://web.archive.org/web/20110828185858/http://jeetworks.com/node/22

Essentially, a remote can have multiple urls. To do this edit your .git/config and put something like this:

[remote "all"]     url = /some/path/to/repo1     url = /some/path/to/repo2 

After that, you can do git push all to push to both of the remote urls pointed to by the remote "all".

like image 51
Grant Limberg Avatar answered Sep 19 '22 05:09

Grant Limberg