my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.7 KiB

3 years ago
  1. # Git auto-fetch
  2. Automatically fetches all changes from all remotes while you are working in a git-initialized directory.
  3. To use it, add `git-auto-fetch` to the plugins array in your zshrc file:
  4. ```shell
  5. plugins=(... git-auto-fetch)
  6. ```
  7. ## Usage
  8. Every time the command prompt is shown all remotes will be fetched in the background. By default,
  9. `git-auto-fetch` will be triggered only if the last auto-fetch was done at least 60 seconds ago.
  10. You can change the fetch interval in your .zshrc:
  11. ```sh
  12. GIT_AUTO_FETCH_INTERVAL=1200 # in seconds
  13. ```
  14. A log of `git fetch --all` will be saved in `.git/FETCH_LOG`.
  15. ## Toggle auto-fetch per folder
  16. If you are using a mobile connection or for any other reason you can disable git-auto-fetch
  17. for any folder:
  18. ```shell
  19. $ cd to/your/project
  20. $ git-auto-fetch
  21. disabled
  22. $ git-auto-fetch
  23. enabled
  24. ```
  25. ## Caveats
  26. Automatically fetching all changes defeats the purpose of `git push --force-with-lease`,
  27. and makes it behave like `git push --force` in some cases. For example:
  28. Consider that you made some changes and possibly rebased some stuff, which means you'll
  29. need to use `--force-with-lease` to overwrite the remote history of a branch. Between the
  30. time when you make the changes (maybe do a `git log`) and the time when you `git push`,
  31. it's possible that someone else updates the branch you're working on.
  32. If `git-auto-fetch` triggers then, you'll have fetched the remote changes without knowing
  33. it, and even though you're running the push with `--force-with-lease`, git will overwrite
  34. the recent changes because you already have them in your local repository. The
  35. [`git push --force-with-lease` docs](https://git-scm.com/docs/git-push) talk about possible
  36. solutions to this problem.