-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
have to pull twice to update a work branch #81
Comments
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. |
I'll check it out. It seems a problem related to git-radar, without it works well. Thanks for the quick response. |
hmm... I'll keep an eye out. I will come back here if I find anything. |
I'm having exactly the same problem here. |
@lucascaton are you getting the same |
@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! 😄 |
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) |
Is there any kind of reproducible pattern that you have noticed? I have been unable to reproduce this problem at all. |
|
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? |
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 |
This isn't my case, no one changes the git history (by using Also, not sure if it helps, but here are my dotfiles: https://github.com/lucascaton/dotfiles. |
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. |
Ok, This just happened to me and I think I have an idea of what's going on. Steps to reproduce:
Theory: |
Thanks Michael, this makes more sense now. |
Please, let me know If anyone comes up with a workaround. |
Any news on this one? |
BTW, my temporary workaround is an alias that runs it twice: |
I've fixed this problem by replacing git-radar with gitHUD. |
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 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 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 |
- First, the script will now add blank lines to your bash_history file - Assumes you use bash - Assumes your history file is in ~/.bash_history - Requires adding 2 lines to your bashrc. Details can be found here: michaeldfallen#81 (comment)
This issue occurs when git-radar is doing a fetch in background and user runs What git-radar should do, is check for the lock file and wait until it is gone before doing a fetch. |
I have this issue too. |
Hi,
I'm using bash in my terminals and I face very often a weird issue that happens when I change to another work branch and make a pull. The first time the pull fails showing the error message below. The second time works fine.
Can anybody point me out in the right direction about what the problem is? Thanks.
The text was updated successfully, but these errors were encountered: