'Pushing Project to Github using Git on Windows
I am trying to push my django project to Gihub
I have installed Github for windows and Git CLI
and followed all the steps
- First created a Repo on github with a ReadMe file (default)
- Created one simple django application
- git init
- git add .
- git commit -m "First Commit"
- git remote add origin https://github.com/eMahtab/DjangoProject.git
- git push origin master
But in last step I am getting error
To https://github.com/eMahtab/DjangoProject.git
! rejected master -> master (fetch first)
error: failed to push some refs to https://github.com/eMahtab/DjangoProject.git
hint: Updates were rejected because the remote contains work that you do not have
locally. This is usually caused by another repository pushing to the same ref. You may
want to first integrate the remote changes (e.g., git pull ...) before pushing again.
See the Note about fast-forwards in git push --help for details.
Solution 1:[1]
Try to do:
git pull
Then you can push.
Solution 2:[2]
This is an often reoccuring problem:
git push github master
To [email protected]:Answer_Bot-project/project.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:Answer_Bot-project/project.git'
An often reoccurring 'solution' is to use a variation of the following commands:
git fetch github; git merge github/master
Git non-fast-forward updates were rejected Merge the remote changes might come in handy, which has a lot of extra information regarding your problem.
Best of luck!
Solution 3:[3]
If a git pull
does not solve your problem, try cloning the project first and copy your code into the cloned project. Proceed as normal. This way git should do the configuration of the remote tracking master branch for you. You just have to do a git push
in the end.
Solution 4:[4]
Omit master because the master is for Mac, if you want to use the command then
type git push origin
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 | ElTĂȘte |
Solution 2 | Community |
Solution 3 | |
Solution 4 | Dani3le_ |