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
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
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>
Source: Stackoverflow.com