'Can't push to private repository
By mistake i pushed .env file to github and then i wanted to hide .env file from my private github repo using .gitignore. For this purpose, i did many stupid things and now it's saying repository not found. Please help me fix this! Now when i do git push, it shows -
fatal: The current branch master has no upstream branch.`enter code here`
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
And if i do git push --set-upstream origin master, it gives me this error -
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Solution 1:[1]
A sensible course of action in your case is:
rename your existing local repository folder
cd /path/to/repo mv warehouse-management-server-side-Arif-Islam warehouse-management-server-side-Arif-Islam.ori
clone the remote GitHub repository again
git clone [email protected]:Arif-Islam/warehouse-management-server-side-Arif-Islam.git
Delete the file incorrectly pushed, but keep it on the disk
git rm --cached -- .env
Update your .gitignore
echo .env >> .gitignore
Add, commit and push
git add . git commit -m "Delete then ignore .env" git push
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | VonC |