Search code examples
gitrepositoryaccount

GIT repository; work with two accounts in same PC


I have Ububntu installed; at work I have my git account, basically to pull, commit and push.

Now I'm starting my own independant project; I will be using the same laptop; I would like to use Git because eventually I will also use the PC I have at home.

So I created a new account with my gmail, now how can I pull, commit and push my project without messing up with the office project??


Solution

  • For an existing git project in your local directory you can do this:

    cd <you-local-git-dir>
    git remote add newrepo https://<your-new-git-url>.git
    git push newrepo master
    

    You can also embed a new user ID to the git URL like this:

    https://userid@host:port/url-path.git
    

    In which case the password could be asked depending on the access rights assigned to your user ID.