For a personal project where I'm the only one creating code, I sometimes switch between two different IDEs. As such, the source code is stored locally in two different places. I would like to have a history/backup of the code on Bitbucket. Is Git able to handle this?
I have foo.cpp
in the directory source_code
. I do not want to copy everything from the remote repo into source_code
. After adding and committing foo.cpp
I try to run git push origin master
and it gives the error
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://bitbucket.org/...'
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.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Like it recommends I do git pull origin master
but it errors with
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
What exactly does unmerged mean in this context? How can I find specifically what files are the issue? I'm guessing the problem is I have files with same name but I only want one specific file tracked from the directory. Such a simple task I would expect to be easy.
When I do git status
it gives
You are currently rebasing branch 'master' on '930b2f7'.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
(use "git rebase --abort" to check out the original branch)
Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both added: foo2.cpp
Bitbucket's version of foo2.cpp was correct so I deleted the local one.I then ran $ git restore --staged foo2.cpp
which worked. Now git pull origin master
works. But still I can't push.
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://bitbucket.org/...'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Again, all I'm trying to do is add a file to the master branch on the remote repo. (Aside, is "remote repo" even the right term to use to refer to a specific project on a hosting service such as Bitbucket?)
Also it says (master|REBASE 2/3)
which I have no clue what it means.