Whats my default git repo for commiting?
If I type git remote -v I get a number of git repos:
origin git@github.com:me/MyProject.git (fetch)
origin git@github.com:me/MyProject.git (push)
testheroku git@heroku.com:test.git (fetch)
testheroku git@heroku.com:test.git (push)
upstream git://github.com:me/MyProject.git (fetch)
upstream git://github.com:me/MyProject.git (push)
I've just done ran "git commit" on the README file and would have expected this开发者_开发技巧 to update the file on MyProject.git - this does not appear to be the case. Am I wrong?
Also, can somebody clarify what upstream is? Does it mean I'm ahead of a branch or what exactly?
Thanks, Gearoid.
Commits are local. You need to push them.
git push origin mybranch # this is probably master in your case
If you do this all the time, you can set up defaults as to which remotes the changes will be pushed. Then you can just
git push
and your changes from any branches will go up to any remotes depending on your configuration. The first time you push, you can
git push -u origin mybranch
and this will set up that branch to automatically be included for pushing to that repository. A subsequent
git push
will be equivelant to
git push origin mybranch
To get more familiar, take a look at
git remote show
git remote show origin
git config -l
Also, you probably don't need the last remote. You can get rid of it with
git remote rm upstream
Hope this helps
When you commit, you're committing to your local repository. Every git working directory has an associated repo.
origin, testheroku, and upstream are all remotes you can easily push and pull from (you can also explicitly use a repo not listed).
If you do:
git push
it will probably (depending on configuration) push to origin
's master
branch automatically.
Also, the first and third appear to to be the same repos, just with different URLs.
You can also create branches as needed locally, but that's a different topic.
git remote -v show
git branch -vv
git config branch.$branch.remote
git remote -v show
shows interesting information about your remotes
The git branch -vv
command will show you your upstream for a specific branch which is probably where you push to by default.
However git config branch.master.remote
would be the only absolute method to know for sure where you push to when you say git push
精彩评论