I have ONE repository on GitHub, let’s call it Repo-1.
I want to first access that repository as a default Git user.
Let’s call that user User-1.
I created SSH keypair, everything fine, works nice.
I made ANOTHER repository on GitHub, let’s call it Repo-2.
I didn’t make any changes in local Git, on my laptop. No configurational changes, nothing.
Now – I want to clone from Repo-1 as the User-2 (but from the same laptop).
First of all: is this at all possible to do?
Can local Git on one single laptop switch between “user accounts” and present itself as User-2? And then, from THAT identity, clone from Repo-1, make some change, and then push to Repo-1?
If possible, how do I do that?
You have your global .gitconfig where you already configured your SSH Keys/User Information. The global .gitconfig is overridden by a local gitconfig – the file “config” in your .git folder (if it does not exist you might have to create it).
For example you can copy the .gitconfig file into the .git folder (and rename it to “config”) and just change the lines you want to change (probably github.user and github.token) or you create a new file with just the two lines in it.
If you prefer the command line “git config” you can avoid all the file moving stuff by omitting the “–global” option.