git multiple remote origin

This question already has an answer here:

  • pull/push from multiple remote locations 14 answers

  • I had the same problem and posted for a solution here.

    Yes you can run multiple projects and for that you just need to run git clone commands from the same place and git will take care of the rest ie create entries and create repo clones in new subdirectories.

    My best option is to --concatenate-- commands and run together if you want to run everything from the same place..

    For example, try this:

    $ cd project1/; git command 1; git command 2; cd..;
    

    Are you running git config --list from within one of your local git repositories (git config exists globally, on a system level, and a local repository level)? And were the contents of git config populated for you, or did you add those yourself?

    I'm not sure if I completely understand what the question is, but it sounds like you want to have four completely separate local git repositories each of which is cloned from a separate bitbucket project.

    Assuming that's the case, you should have a different local repository for each of them. You would set that up like so:

    $ git clone git@bitbucket.org:username1/project1.git
    $ git clone git@bitbucket.org:username2/project2.git
    $ git clone git@bitbucket.org:username3/project3.git
    $ git clone git@bitbucket.org:username4/project4.git
    

    Which would provide you with the following directory structure:

    .
    ├── project1/
    │   ├── .git/
    │   └── ... (project contents)
    ├── project2/
    │   ├── .git/
    │   └── ... (project contents)
    ├── project3/
    │   ├── .git/
    │   └── ... (project contents)
    └── project4/
        ├── .git/
        └── ... (project contents)
    

    If you move into any of these directories and run git remote -v , you'll see that each one has a remote called origin and points to a different repo. Whenever you clone a git repository, a remote called origin is automatically created for you each time and points to the repository that you cloned from.

    $ cd project1/
    $ git remote -v
    origin  git@bitbucket.org:username1/project1.git (fetch)
    origin  git@bitbucket.org:username1/project1.git (push)
    
    $ cd ../project2/
    $ git remote -v
    origin  git@bitbucket.org:username2/project2.git (fetch)
    origin  git@bitbucket.org:username2/project2.git (push)
    

    Or, as you demonstrated, you can see your remotes with git config --list :

    $ cd project2/
    $ git config --list
    ...
    remote.origin.url=git@bitbucket.org:username2/project2.git
    remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
    ...
    

    Pushing and pulling is easy:

    $ cd project3/
    $ git pull
    $ git push origin master
    
    链接地址: http://www.djcxy.com/p/49768.html

    上一篇: 我怎么能在同一时间推到两个回购

    下一篇: git多个远程起源