Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 98 lines (64 sloc) 3.149 kb
673fd51 @simonthum initial commit
authored
1 # git-sync
2
3 sychronize tracking repositories
4
5 2012 by Simon Thum
6
7 This scrips intends to sync near-automatically via git
8 in "tracking" repositories where a nice history is not
9 as crucial as having one.
10
11 Licensed under CC0
12
13 ## One more git sync script? Seriously?
14
15 Unlike the myriad of scripts to do just that already available,
e4cccc5 @simonthum emphasize safety
authored
16 it follows the KISS principle: It is safe, small, requires nothing but
673fd51 @simonthum initial commit
authored
17 git and bash, but does not even try to shield you from git.
18
19 It is ultimately intended for git-savy people. Tested on msysgit and a
20 real bash. In case you know bash scripting, it will probably make your
21 eyes bleed, but for some reason it works.
22
23 ### What does it do?
24
25 It will likely get from you from a dull normal git repo with trivial
26 changes to an updated dull normal git repo equal to origin. No more,
27 no less.
28
e4cccc5 @simonthum emphasize safety
authored
29 Care has been taken that any kind of problem, pre-existing or not,
30 results in clear error messages and non-zero return code, but of
31 course no guarantee can be given.
32
673fd51 @simonthum initial commit
authored
33 The intent is to do everything that's needed to sync
34 automatically, and resort to manual intervention as soon
35 as something non-trivial occurs. It is designed to be safe
36 in that `git-sync` will likely refuse to do anything not known to
37 be safe.
38
39 ### How am I supposed to use it?
40
41 Just call `git-sync` inside your average joe's repository (not in the
42 middle of a rebase, git-am, merge or whatever, not detached, no
43 untracked files) and everything will likely just work. If you don't
44 push in an intertwined manner, `git-sync` is virtually guaranteed to work.
45
46 ## How does it work?
47
48 The flow is roughly:
1e73801 @simonthum try fix list in readme
authored
49
8baa9b9 @simonthum use language, not fancy formatting.
authored
50 1. sanity checks. You don't want to do this in the middle of a rebase.
51 2. Check for new files; exit if there are, unless allowed in config.
52 3. Check for auto-commitable changes.
53 4. perform auto-commit
54 5. one more check for leftover changes / general tidyness
55 6. fetch upstream
56 7. Relate upstream to ours. If ahead, push. If behind, pull. If diverged, rebase, then push.
57 6. At exit, assert sync state once more just to be safe.
673fd51 @simonthum initial commit
authored
58
59 On the first invocation, `git-sync` will ask you to whitelist the
60 current branch for sync using git config. This has to be done once for
61 every copy.
62
63 ## Options
64
65 There are two `git config`-based options for tailoring your sync:
66
67 branch.$branch_name.syncNewFiles (bool)
68
69 Tells git-sync to invoke auto-commit even if new (untracked)
70 files are present. Normally you have to commit those yourself.
71
72 branch.$branch_name.autocommitscript (string)
73
74 A string which is being eval'ed by this script to perform an
75 auto-commit. Here you can run a commit script which should not
76 leave any uncommited state. The default will commit modified or
77 all files with a more or less useful message.
78
79 By default commit is done using:
80
81 git add -u ; git commit -m "changes from $(uname -n) on $(date)"
82
83 Or if you enable `syncNewFiles`:
84
85 git add -A ; git commit -m \"changes from $(uname -n) on $(date)\";"
86
87 # License
88
89 I declare this work to be useable under the provisions of the CC0 license.
90
91 http://creativecommons.org/publicdomain/zero/1.0/
92
93 Attribution is appreciated, but not required.
94
95 # Thanks
96
97 Thanks go to all the people behind git.
Something went wrong with that request. Please try again.