ProjectInitializationAutomation icon indicating copy to clipboard operation
ProjectInitializationAutomation copied to clipboard

Username conflict issue affecting git remote add

Open HughG-50 opened this issue 4 years ago • 2 comments

I found the issue on my Mac machine, with retrieving the username from the .env file. The issue arose because my Github and Mac machine usernames were different.

On the following line in create.py username = os.getenv("USERNAME")

My Mac machine username was somehow being retrieved instead of the Github username I had set in the .env file. This was causing the command git remote add origin <[email protected]:$USERNAME/$1.git> to insert the wrong username, causing it to fail.

Renaming the USERNAME to GITHUBUSERNAME in the codebase alleviated the issue.

That is, and in the .env files, the following was changed:

In create.py username = os.getenv("GITHUBUSERNAME")

In .my_commands.sh git remote add origin https://github.com/$GITHUBUSERNAME/$1.git

And .env file GITHUBUSERNAME="<my_username>"

HughG-50 avatar Apr 18 '20 10:04 HughG-50

Most probably this is happening because the USERNAME is a OS reserved environmental variable. Like maybe Mac saves your username in a env with the same namespace.

ThatAnonyG avatar Jul 13 '20 13:07 ThatAnonyG

I have created a same script as this to work on every machine

DO NOT WORRY THIS SCRIPT WORKS ON EVERY MACHINE

Link to the project: https://github.com/String-error-404/GIT-and-GTITHUB_automation

if you like the project give a star to the repo and follow me on github

terminal-guy avatar Aug 12 '20 06:08 terminal-guy