Git pull command from different user
GitGithubGit Problem Overview
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
Git Solutions
Solution 1 - Git
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
Solution 2 - Git
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
Solution 3 - Git
Your question is a little unclear, but if what you're doing is trying to get your friend's latest changes, then typically what your friend needs to do is to push those changes up to a remote repo (like one hosted on GitHub), and then you fetch or pull those changes from the remote:
-
Your friend pushes his changes to GitHub:
git push origin <branch>
-
Clone the remote repository if you haven't already:
git clone https://[email protected]/abc/theproject.git
-
Fetch or pull your friend's changes (unnecessary if you just cloned in step #2 above):
git fetch origin git merge origin/<branch>
Note that
git pull
is the same as doing the two steps above:git pull origin <branch>