Under the same remote git repository:
Use origin to specify the alias of the remote repository.
Now create multiple projects locally, and when using git init and git remote add origin git@github.xxx.xxx in each project, you will be prompted that origin already exists.
The current operation is: every time I switch to another project, I use git remote rm origin to delete the original origin and then specify the origin location of the new project. I suspect that I am stupid. . .
Under different remote git repositories:
For example,
In github: when creating a remote repository locally, use github as an alias for a project in the remote repository
In gitlab: when creating a remote repository locally, use gitlab as the remote The alias of a certain project in the warehouse
is used when creating a remote warehouse locally on bitbucket: Bitbucket is an alias for a project in the remote warehouse
. This difference is easier to distinguish. So what if there are multiple projects under the same remote warehouse that need to be developed and maintained?
How to associate the local warehouse with it?
淡淡烟草味2017-05-02 09:39:07
You can use git remote add name2 https://github.xxx to add multiple remotes
Are there multiple projects under the same remote warehouse? What does it mean.
To establish a connection between local and remote:
1 If there is no working directory locally, just git clone URL
2 If there is already a working directory locally,
a currently does not use git management, git init && git add remote origin URL && git push origin master
b is currently managed by git, git add remote other_name URL && git fetch other_name && git checkout branch
PHPz2017-05-02 09:39:07
What does it mean? Originally, your different projects have different origins when you git clone them. Whichever project you enter will have the origin of that project, which is configured in the .git/config of the current project. There is no need to delete or change it at all
巴扎黑2017-05-02 09:39:07
No need for an alias? Direct warehouse address?
git push git@github.com:aaa/bbb.git develop
黄舟2017-05-02 09:39:07
Everyone! ! ! Why does a newly created project show that origin already exists? I finally noticed it because I had already performed a git init operation before creating the superior folder of the project. . .
so, different projects can use the origin alias for the corresponding warehouses associated with the same remote git. That is, when the local warehouse is associated with the remote warehouse, git inti 》》git remote add origin URL 》》 git push -U origin master .
The above, I finally understand it today.