i have struggled to implement git as my version control system on numerous occasions... so frustrated. read numerous articles and tutorials. searched but can't seem to create a search that addresses what i need to know. In this attempt i am trying to do the following. Tell me if this is wrong please.
- MAIN BARE REPO: create a bare repository on my development machine that i can push changes to (done. currently has nothing in it.)
- DEVELOPMENT BRANCH REPO: initiate a repository in the directory that i can make changes in and then push to the bare repository. (done. completed the first commit.)
- PRODUCTION BRANCH REPO: initiate a repository on my host to pull updates from the bare repository. (not done yet.)
I thought that #1 and #2 were almost done when i attempted to push f开发者_如何学编程rom DEVELOPMENT to MAIN BARE REPO and got:
no origin was found for working tree
Do i need to set the MAIN BARE REPO as the origin? Is there a command to do that? I'm afraid to ask for an article because most of the material that is written on git i have a really hard time applying for some reason.
If the answer is:
git push --all <url-of-bare-repo>
What does that look like with the following information?
- The development branch that i'm pushing from is located at /Users/me/sites/devel_repo
- The main bare repo that i'm pushing to is located at /Users/me/sites/main_repo
Thanks.
origin
is a remote.
You can add it like this from your DEV repo:
git remote add origin path/to/bare/repo
So in your case, it will be like:
git remote add origin /Users/me/sites/main_repo
Once this is done, you can issue the git push origin master
etc.
Generally, when you clone from another repo, this origin
is automatically setup. It is just a convention and a default. You can have some other name if you like.
Also, note that, to push, it is not necessary to have a remote. It is just a short-hand to a repo path / url so that you don't have to repeat it again and again. It looked for origin when you pushed because when you do git push
, it by default tries to push to origin.
精彩评论