3

I setup a git server days ago in the lab. I am trying to create two repositories on the same server with name origin and myprj so to maintain two separate projects. I am following the post pull/push from multiple remote locations and GIT repository layout for server with multiple projects

I create a new repository as

git remote add myprj https://xxx.yyy.zzz/repo.git 

and it shows me

git remote
origin
myprj

I create a clone on the local computer and it clones the origin repository and master branch, in which I have two files a.txt and b.txt. But the new repository myprj does not have any file yet.

I am trying to fetch the myprj as

git fetch myprj

I got

From https://xxx.yyy.zzz/repo.git
 * [new branch]    master    -> myprj/master
 * [new branch]    myprj     -> myprj/myprj

But this does not update the local folder. I also try

git pull myprj master
From https://xxx.yyy.zzz/repo.git
 * branch    master    -> FETCH_HEAD
Already up-to-date.

But the local folder is not sync with the remote myprj repository. I think I must misunderstand the concepts on repository. I am learning how to easily switch between different repositories on the same server so I can maintain it locally and upload to the remote server later.

p.s. I clone origin/master to the local folder which .git created by git client. In the local folder, I create A.txt and then

git checkout -b origin/master
git add A.txt
git commit -a -m 'this is on origin master'

then I create B.txt for myprj only

git checkout -b myprj/master
git add B.txt
git commit -a -m 'this is on myprj master'

What I expect is after I checkout different repository, should I see the local file changed to refect which files contained in the repository by the client? I found that if I create branch on the same repository, switching between different branch will see the different contents.

Community
  • 1
  • 1
user1285419
  • 2,183
  • 7
  • 48
  • 70
  • so you have two files on origin and local, and nothing on myprj. Why don't you push your files to myprj to have it in sync? – eis Jun 10 '15 at 19:24
  • Sorry for confusing. I mean when I create the myprj, I don't have file to upload there. But I am trying to upload something there my seems everything I commit will go to origin/master instead. – user1285419 Jun 10 '15 at 19:36
  • Could you mark which of the above commands are run on server and which on client? –  Jun 10 '15 at 20:02
  • Thanks for reply. Do you mean where I run those commands? All commands are run on the git bash client, but I think the one with remote will act on the remote site (let me know if I am wrong). – user1285419 Jun 10 '15 at 20:12
  • Please, instead of describing what you do, post a transcript. "I create a new repository as git remote add myprj https://xxx.yyy.zzz/repo.git " -- if that's really what you did -- didn't create a repository at all. – jthill Jun 10 '15 at 20:19
  • The link is not accessible from internet, it is an internal server, I am showing an example there. Sorry for the confusing. – user1285419 Jun 10 '15 at 20:22
  • 2
    It seems to me that what you're trying to achieve is to work with two remote repositories that contain _different_ code. In that case, just clone them into two different directories; don't use `git remote`. That command is only useful when you have multiple remote repositories that contain the _same_ code. – Aasmund Eldhuset Jun 10 '15 at 20:31
  • 1
    Yes, that's what I am trying to do. I think I get your suggestions, it looks good to clone that into different folders instead. thanks. – user1285419 Jun 10 '15 at 20:38
  • by the way, if you want to have a mirror remote project, you can use the `git push --mirror https://github.com/xxx/xxx.git` to achieve that. – einverne Jun 11 '15 at 01:59

0 Answers0