A friend and myself are sharing my computer. I\'ve made pushes to GitHub using the git bash shell on Windows 7. Now we\'re in a different project on that computer and I need
It's simple while cloning please take the git URL with your username.While committing it will ask your new user password.
Eg:
git clone https://username@github.com/username/reponame.git
git clone https://username@bitbucket.org/username/reponame.git
If you have https://desktop.github.com/
then you can go to Preferences (or Options) -> Accounts
and then sign out and sign in.
I setup an ssh alias using a custom IdentityFile and rewrote the origin to use my custom me-github hostname.
#when prompted enter `id_rsa_user1` as filename
ssh-keygen -t rsa
# ~/.ssh/config
Host user1-github
HostName github.com
Port 22
User git
IdentityFile ~/.ssh/id_rsa_user1
#check original remote origin url
git remote -v
origin git@github.com:user1/my-repo.git
#change it to use your custom `user1-github` hostname
git remote rm origin
git remote add origin git@user1-github:user1/my-repo.git
git config user.name only changes the name I commit. I still cannot push. This is how I solved it, and I think is an easy way to me.
Generate a SSH key under the user name you want to push on the computer you will use https://help.github.com/articles/connecting-to-github-with-ssh/
Add this key to the github user account that you want to push to https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
Choose to Clone with SSH
You can push in as this user to that repo now.
this, should work:
git push origin local-name:remote-name
Better, for GitLab I use a second "origin", say "origin2":
git remote add origin2 ...
then
git push origin2 master
The conventional (short) git push should work implicitly as with the 1st "origin"
The userid where the commit happens is stored in the config file.
go to the top of the repository vi .git/config
change the url line listed after "[remote "origin"] to have the appropriate userid