I am trying to push some code to Bitbucket, the remote repo that I have already cloned and initialized on my local computer. However, there are two files and I am trying to push changes to only one, named Ccode. I cd to the local directory (Ccode) and did:
git add .
git commit -m 'Updates'
git push
but I get:
! [rejected] master -> master (fetch first)
error: failed to push some refs to..
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
So, I try git pull
It takes me to another window to write the git merge message. I am not sure why but ends up not working
hint: Waiting for your editor to close the file... error: There was a problem with the editor 'vi'.
Not committing merge; use 'git commit' to complete the merge.
I don't know what is the point of merge really and I am trying to pull changes from the second file not Ccode file and push only to the Ccode file. I am sort of confused really, and do not want to cause issues for someone else's repo.
I don't know what is the point of merge really and I am trying to pull changes from the second file not Ccode file and push only to the Ccode file.
git pull
fetches and downloads the content from the remote repo to your local one. Sometimes this can result in conflicts e.g. you may have changed files in your local repo that have also been changed in the remote repo. git merge
is used to integrate changes from another branch i.e. branch from the remote repo to your local one. You also might want to read about merge conflicts.
hint: Waiting for your editor to close the file... error: There was a problem >with the editor 'vi'. Not committing merge; use 'git commit' to complete the merge.
For the issue you were having regarding the commit editor, it seems that git
can't seem to find the vi
text editor which is the fallback option if you haven't explicitly set your preferred editor.
From the docs:
core.editor
By default, Git uses whatever you’ve set as your default text editor via one of the shell environment variables VISUAL or EDITOR, or else falls back to the vi editor to create and edit your commit and tag messages.
If you have vi
installed try using the full path or if you want to use another text editor, you can do so with:
$ git config --global core.editor /path/to/editor