How to push codes to github
1) Go to command prompt by pressing on Windows Key and type "cmd"
2) Go to your folder which you want to push your code to github by doing "cd directory/to/app
3) Do "git init"
4) Do "git add ."
5) Do "git commit -m "Commit message"
6) Do "git branch -M main"
6) Do "git remote add origin <github link>"
example: "git remote add https://github.com/Cawleeflower/tutorial-env.git"
example: "git remote add https://github.com/Cawleeflower/tutorial-env.git"
7) Do "git push -u origin main"
Errors that may occur:
1) fatal: unable to access 'https://github.com/<github-name>/<repo-name>.git/': The requested URL returned error: 403
For this error, you'll just need to add "<github-name>@" preceding the 'https' and 'github.com' like so:
"git remote set-url origin "https://<github-name>@github.com/<github-name>/<repo-name>.git/'
Please note that this is just a workaround.
2) error: src refspec <branch> does not match any
error: failed to push some refs to 'github-link'
For this error, you are pushing your source code from the wrong local branch. To fix this, run git branch -M <branch> and it should work.
3)remote: Repository not found.
fatal: repository 'https://github.com/<github-name>/<repo-name>.git/' not found
Refer to the first error, the solution is the same.
4) I can't find my source code when I'm on github??
You are probably seeing the contents of another branch. You can click on the dropdown list that indicates the name of your branch and you should see another branch other than "main".
Comments
Post a Comment