Running git on windows 10, I get similar problems on different git-applications (git GUI, git on UBUNTU shell, git in terminal).
It's the same behaviour on all my projects and different computers, making me suspecting that something is wrong with my account. The problem started a couple of months ago, did not have any problems before that.
git pull
error: cannot lock ref 'refs/remotes/origin/master': Unable to create '/mnt/c/users
/simon/Dropbox/Universitet/dark/datorarkitektur/.git/refs/remotes/origin/master.loc
k': File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
From https://git.cs.umu.se/c18sjn/datorarkitektur
! 7b1722c..c2c55fa master -> origin/master (unable to update local ref)
I remove the .lock file located in .git/refs/remotes/origin/master.lock but it is generated every time I pull. I have tried to remove all my editors with integrated GIT functionality and terminated all processes except one terminal.
If my branch is behind I am able to pull (with similar warnings but does work) and then push, but I am not able to push at all if my branch is ahead before the pull (because the pull fails). Example of push:
git push
To https://git.cs.umu.se/c18sjn/datorarkitektur.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.cs.umu.se/c18sjn/datorarkitektur.git' hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
While many people suggest putting a Git repository into Dropbox, there are problems. From the git-remote-dropbox FAQ...
Why shouldn't I keep my Git repository in Dropbox and let the client sync it?
...The desktop client is not aware of how Git manages it's on-disk format, so if there are concurrent changes or delays in syncing, it's possible to have conflicts that result in a corrupted Git repository. This may be uncommon with the way the timing works out in the single user case, but it's still not safe!
Dropbox is designed for syncing files. Git is not aware of this. You effectively have multiple uncoordinated users trying to use the same local repository at the same time. Dropbox can "sync" Git repository files and corrupt the repository. For example, it can resurrect a lock file.
git-remote-dropbox
fixes those problems.
This Git remote helper makes Dropbox act like a true Git remote. It maintains all guarantees that are provided by a traditional Git remote while using Dropbox as a backing store. This means that it works correctly even when there are multiple people operating on the repository at once, making it possible to use a Dropbox shared folder as a Git remote for collaboration.
After installing it, don't use Dropbox for your checked out repository. Move your repository out of Dropbox and into a normal directory, work on your code from there. Use Dropbox only for the remote repository.
Declare the remote using a dropbox
URL.
git remote add origin "dropbox:///mnt/c/users
/simon/Dropbox/Universitet/dark/datorarkitektur/"
Next time you push it will make a remote repository in /mnt/c/users/simon/Dropbox/Universitet/dark/datorarkitektur/
.
It's possible you might need a git fsck
to get out of your current state. Then things should work more smoothly going forward.