I am new to github. I have been working on a code that I fetched from github. Now I completed making my modifications and I want to push my code to github. I would like to create a fork of the original code that I worked on and push my developed code over that fork. However while I was working on development there has been some changes at the original code. So when I try to push my new code to the fork I get the following error:
git push original master
To https://github.com/<username>/<projectName>.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/<username>/<projectName>.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
Then I used
git pull
which outputted the following:
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
I can’t continue from this point on. What should I do to commit my project?
Well, git is telling you what to do. If you want to pull, you need to finish the incomplete merge first.
Git statusshould tell you what files are as yet unmerged. You need to resolve the merge conflicts and then usegit addon the file(s) to tell git that the conflict is resolved.With that said, if your goal is to work off a fork, you should fork the code first, clone the forked code, make your modifications to it, and then push your changes back to the fork. Once that’s done, you can submit a pull request to the authors of the original project to integrate your changes.