5

I have a repo for my dotfiles and update it here and there on various computers. Sometimes I forget to git pull before editting and git push. This creates conflicts or trigger git merge, or I just forget that I wrote a new feature somewhere else already. So, how do I do the following:

  1. check every n minutes for remote repo changes and give a message to the current frame so I can pull the changes before doing something else.
  2. When opening (find-file) on the repo, do the same check changes and notification.
  3. (expansion for other use cases) if I am not working on the repo, but I still want to get notitfy about changes on a list of repos something like this: ((repo1 "git@host:/path/to/repo1") (repo2 "git@github.com:user/repo2"))

    if there are changes on repo1 then I will get a notification saying "There are changes on repo1. Check it out!"

  • there is the magit-status-refresh-hook that you can attach a pull to – Jules Apr 15 '16 at 21:01
1

I would recommend against setting up some mechanism to automatically pull. Personally I avoid even pulling manually. What I usually do instead is to first only fetch. Once I have done that I can see what new commits, if any, were "created elsewhere". I can then inspect those changes and decide, on a case by case basis, whether it is appropriate to merge or to rebase.

Usually I rebase, which can be done using r, followed by u or e <branch> RET as appropriate.

If after doing it explicitly like this for a while, you find that you always rebase (and I would assume that for dotfile repositories this might actually be the case), you can also configure pull to always rebase. To do so type b to bring up the branch configuration popup and then type M-r until true is highlighted on the pull.rebase line (i.e. set the repository-local value of pull.rebase to true). Alternatively you can configure just the current branch to be always rebase, using the same popup.

  • I can partially agree with not automatic pull, but still want to do get automatic notification. I think I have some clues, I will implement it and come back later – biocyberman Apr 22 '16 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.