Comments (22)
This issue occurs when git-radar is doing a fetch in background and user runs git fetch/pull
. Git has index.lock
to lock index during a fetch, so you cannot corrupt the index by doing concurrent fetches. Your git command fails because of this lock prevents git modifying index.
What git-radar should do, is check for the lock file and wait until it is gone before doing a fetch.
from git-radar.
Have you checked stack overflow? I found this which looks like a similar problem to yours.
Is this problem specific to git-radar? Because It appears that similar error occurs without it.
I have not had this problem ever, and not with git-radar either.
from git-radar.
I'll check it out. It seems a problem related to git-radar, without it works well. Thanks for the quick response.
from git-radar.
hmm... I'll keep an eye out. I will come back here if I find anything.
from git-radar.
I'm having exactly the same problem here.
from git-radar.
@lucascaton are you getting the same Ref refs/remotes/origin/<branch> is at foo but expected bar
message? Suggests that the background fetch isn't working correctly.
from git-radar.
@michaeldfallen I guess the background fetch is working well - I can see the arrows icons changing automatically from time to time:
I tested about 10 times right now with different repos, it looks like the problem doesn't happen anymore! 😄
from git-radar.
Well, it just happened again 😞
$ git pull --rebase
error: cannot lock ref 'refs/remotes/origin/master': ref refs/remotes/origin/master is at 65735d3e448b88a9ca7e09596579090d7466deb7 but expected 97dbc8873fa32a83c17378628d072cd52c35dec6
From github.com:foo/bar
! 97dbc88..65735d3 master -> origin/master (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/branch1': ref refs/remotes/origin/branch1 is at 1e6b13817159a8087454aa7d10415c9ed9174629 but expected 0322ea944c7460a8751fa87df2f95a4e48b24c44
! 0322ea9..1e6b138 branch1 -> origin/branch1 (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/branch2': ref refs/remotes/origin/branch2 is at 2465da7a5d5943f47177b55846dbb46e8b74d720 but expected 0622a9c2f945751cfb91887456153a13b7ffc499
! 0622a9c..2465da7 branch2 -> origin/branch2 (unable to update local ref)
from git-radar.
Is there any kind of reproducible pattern that you have noticed? I have been unable to reproduce this problem at all.
from git-radar.
--rebase
maybe?
from git-radar.
I use --rebase and I have not seen this problem with that command. I have found these which show similar issues:
http://stackoverflow.com/questions/12416643/notorious-git-error-remote-rejected-failed-to-lock
http://emacs-devel.gnu.narkive.com/YJDjId4U/git-error-on-master
Maybe these will help. I will see if I can reproduce the problem and come back if I find anything.
Out of curiosity, what version of git are you using?
from git-radar.
I've noticed this can also sometimes happen if you are working with someone that has modified the git history that has already been pushed. Perhaps this is the case?
The comments of the question above says some about this.
Maybe every once in a while check the log of your local rep and compare it to the remote and see if a commit has been added to the middle or a commit in the middle has been changed in some way
from git-radar.
This isn't my case, no one changes the git history (by using git push --force
for example).
Also, not sure if it helps, but here are my dotfiles: https://github.com/lucascaton/dotfiles.
from git-radar.
I've seen this problem when I have to switch to another branch whose origin has been updated by someone else, so my local copy is some commits behind the origin. I change to that branch, I run a "git pull" and I see the error message. Then, when I run "git pull" for the second time, everything works well.
Besides that, sometimes, the first time I move to another branch I don't see the git prompt info regarding to the number of commits to download, I can see that info after the first "git pull" that shows the error message.
from git-radar.
Ok, This just happened to me and I think I have an idea of what's going on.
Steps to reproduce:
- Wait until after the 5 minute fetch time limit
- Have someone else update a branch on the remote (push new commits for example)
- Hit enter (triggering a fetch in the background)
- run
git pull
quickly error: cannot lock ref 'refs/remotes/origin/master': ref refs/remotes/origin/master is at 7e7a2e551538f12fe8fe843a32f764e23075651e but expected c8599fadc27e88032933ab9ff0b4b44f88e662f6
Theory:
When you hit enter it triggers a fetch. The file .git/refs/remote/origin/master
is locked by the background fetch job. When you git pull it can't update the ref because it's currently locked. Once that first pull fails the fetch has succeeded by then and the second pull passes just fine.
from git-radar.
Thanks Michael, this makes more sense now.
from git-radar.
Please, let me know If anyone comes up with a workaround.
Thanks,
from git-radar.
Any news on this one?
from git-radar.
BTW, my temporary workaround is an alias that runs it twice:
https://github.com/lucascaton/dotfiles/blob/master/files/zshrc#L67
from git-radar.
I've fixed this problem by replacing git-radar with gitHUD.
from git-radar.
I haven't had a chance to look into this for a while, but I do have a (probably) better workaround.
in the git-radar script if we do:
if [[ "$command" == "--fetch" ]]; then
his=$(cat ~/.bash_history | tail -n1)
if [[ "$his" != *"git pull"* && "$his" != *"git fetch"* ]]; then
nohup $dot/fetch.sh >/dev/null 2>&1 &
else
echo " " >> ~/.bash_history
fi
fi
This stops the fetch function of git radar from running when the user runs git pull
or git fetch
es. The echo
in the else
pushes an empty line on the bottom of the history file. Unfortunately without doing this, if I enter a git pull
command, and then just press enter at the prompt without typing anything the script would still think you entered a git pull
command. I could not think of a better way to do this
I would push a pull request for this, but it still has some issues. The above issue being one of them.
The second is, (assuming you use bash) you need to add these two lines to your bashrc:
shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
The first line says to append to the bash_history file. The history -a
in the second line forces the last entered command into the history file. I put it in PROMPT_COMMAND
because the commands inside this variable are executed every time the prompt is written.
The other issue is that I don't know how this will (or will not) work for other shells, since I don't use any other shell. ie. the script currently expects that you are using bash, and that your bash_history file is in ~/.bash_history.
I tried using $HISTFILE instead, but that seems to hang the script for some reason.
I could also require everyone to export a variable in their bashrc for the location of the history file, but that is just more configurations that we probably don't want.
Assuming however that you do not mind having blank spaces added to the bottom of your history file, or you do not mind adding some lines to your bashrc, this does actually seem to work.
@michaeldfallen if you would accept this in some way (making it an optional feature, giving instructions about how to do this in the readme, including a variable in the bashrc to point at the history file etc) let me know, and I can definitely do that
from git-radar.
I have this issue too.
from git-radar.
Related Issues (20)
- is_cwd_a_dot_git_directory:1: = not found HOT 7
- Promote new Maintainers HOT 4
- Calling Formula.sha1 is deprecated! HOT 4
- Calling Formula.sha1 is deprecated! HOT 2
- Not upstream indicator taking up too much space HOT 12
- problem with fish HOT 2
- Weird issue with Makefile HOT 2
- Running git-radar --bash is slow HOT 3
- Fish - LS is completely bugged HOT 2
- command overlaps prompt with stash HOT 1
- odd sed error on branches named with multiple / characters HOT 7
- Made a new lightweight stable version of git-radar HOT 2
- weird characters show up with git-radar on mac os x HOT 8
- fatal error messages with git-radar on local untracked branches HOT 11
- Unhandled git error when a tracked upstream branch is removed HOT 2
- 0.6 upgrade issue HOT 3
- feature req: color prompt red when folder not writable HOT 1
- Reduce the number of binaries needed to be added to the path HOT 3
- cd .git/ produces fatal: /usr/lib/git-core/git-stash cannot be used without a working tree HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git-radar.