0

Currently my friend and I are using sharing VM and are using git to keep track of changes. A problem occurs when he tries to commit since the VM is under my name. Since the VM is mine and the git repo has been established with my name, bitbucket (an online git repository) thinks im the user thats pushing the code them and registers it under my name although my friend is using his personal remote. So is there a way for both of us to share a database for development purposes without having to share a VM or is there a way to switch users in git instead? I need to find a way for my friends commits to be registered as his own for tracking purposes.

P.S. I think I need to make it clear that we are both currently using the same machine but even when he pushes code using his remote url, bitbucket registered the commit as my own.

the only reason he is still using my VM is the fact that we are noobs and dont know how to share a database while he works and commits from his own VM

John Saunders
  • 160,644
  • 26
  • 247
  • 397
alaboudi
  • 3,187
  • 4
  • 29
  • 47
  • 1
    Add him as an admin to the repo? Or atleast with Write access? P.s, wouldn't he simply branch the repo for his own and merge at a later date..? – Darren May 15 '15 at 00:30
  • So both you and your friend are developing on the same machine? – slebetman May 15 '15 at 00:31
  • hey @Darren thanks for getting back to me. He has write access to my repo. its just that we are currently using the same machine as we need to share a db – alaboudi May 15 '15 at 00:32
  • @slebetman yes we are using one machine online together – alaboudi May 15 '15 at 00:32
  • do you have root access to the VM? That is, can you create a new user account? – slebetman May 15 '15 at 00:36
  • yes I do have root access. and creating a new user is a good suggestion. But do you know how I may share a db with him without the entire VM? If i am able to do so, he can work off his own VM and then pull and push normally too. I just want to explore my options :D – alaboudi May 15 '15 at 00:38
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders May 15 '15 at 01:36

1 Answers1

1

The simplest way is for your friend to edit code in his own folder. It may feel like you're wasting disk space but all other solutions require even more disk space. This way, you don't need another VM or even another user account on your VM.

  1. git clone the repo again into another folder:

    mkdir your_friend
    cd your_friend
    git clone [bitbucket url to your repo]
    
  2. Configure the .git/config file inside the folder correctly so that commits made in this folder will belong to your friend. You can use the git config command for this. Just don't use the --global flag.

  3. Have your friend use this folder to do his edits.

  4. Pull and push code to bitbucket to synchronize your work. This simulates two developers working on two different PCs.

The advantage of this setup is that it familiarizes you to pulling and pushing code (and merging). Later when you have separate PCs to do development you don't have to change your habits.

Hint: Google "git flow" for a nice setup/workflow for projects with multiple developers.

slebetman
  • 109,858
  • 19
  • 140
  • 171
  • thanks for the answer @slebetman. I didnt think of that. but why did bitbucket register his earlier commit under my name although he used his remote? you did provide an answer but I dont see why the same thing wont just happen again with this different folder – alaboudi May 15 '15 at 00:46
  • Your settings such as your username and email address that's used for commit logs are stored in the project folder inside `.git/config`. Setting things correctly in there will ensure that changes to each folder will be marked as the correct user. I'll add it to my answer. – slebetman May 15 '15 at 01:23