1

My git config --list looks like this

core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@bitbucket.org:username/project1.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
include.path=/var/www/__/subfolder/

Question 1: Can I add multiple remote origins for multiple projects?

Question 2: if yes then how do I manage multiple repos after adding them here? (or how do I run add commit pull and push for every repo)

Anthem
  • 69
  • 7
  • 1
    @Jubobs no sir the situtaion of the link you shared is completely different. My repos are all separate and they can't be mixed up with each other. – Anthem Sep 03 '15 at 16:07
  • 1
    Could you explain in more detail? When you say they're separate, what do you mean, it's still the same codebase right? – dpcasady Sep 03 '15 at 16:21
  • @dpcasady I have got clone from bitbucket which are from 4 different users and 4 different projects (no connection to each other). – Anthem Sep 03 '15 at 17:12
  • Sorry, but can you clarify why you need 4 urelated projects in the same repo, maybe you need to add them as submodules instead. – joran Sep 03 '15 at 21:08

2 Answers2

1

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 i.e. 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..;
Bengali
  • 198
  • 2
  • 13
0

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
dpcasady
  • 1,826
  • 12
  • 30