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