Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull command from different user

Tags:

git

github

I am working with my friend on a project the code of which is on Git. If I need to pull the changes from my friend's machine, can I pull it from my username/password using the following command without any issue?

git pull https://[email protected]/abc/theproject.git 
like image 284
Mohsin Inayat Khan Avatar asked Jun 19 '14 11:06

Mohsin Inayat Khan


People also ask

How do I pull from one Github account to another?

Using the command lineGo into the directory for your project. Add a connection to your friend's version of the github repository, if you haven't already. Pull his/her changes. Push them back to your github repository.

How do I switch users in git?

Open your terminal and navigate to your git repository. Change Git user name by running: git config --global user.name “Your Name” Change Git user email by running: git config --global user. email “[email protected]

Can you pull from another branch git?

just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.


2 Answers

This command will help to pull from the repository as the different user:

git pull https://[email protected]/projectfolder/projectname.git master 

It is a workaround, when you are using same machine that someone else used before you, and had saved credentials

like image 174
Davlet D Avatar answered Oct 13 '22 06:10

Davlet D


Was looking for the solution of a similar problem. Thanks to the answer provided by Davlet and Cupcake I was able to solve my problem.

Posting this answer here since I think this is the intended question

So I guess generally the problem that people like me face is what to do when a repo is cloned by another user on a server and that user is no longer associated with the repo.

How to pull from the repo without using the credentials of the old user ?

You edit the .git/config file of your repo.

and change

url = https://<old-username>@github.com/abc/repo.git/ 

to

url = https://<new-username>@github.com/abc/repo.git/ 

After saving the changes, from now onwards git pull will pull data while using credentials of the new user.

I hope this helps anyone with a similar problem

like image 33
gunj_desai Avatar answered Oct 13 '22 06:10

gunj_desai