]> git.xonotic.org Git - xonotic/xonotic.wiki.git/blob - Git.md
./all compile was missing
[xonotic/xonotic.wiki.git] / Git.md
1 Git
2 ===
3
4 Cloning the repository
5 ----------------------
6
7 Expected time (~2.5MiB/s): ~2m (initial checkout) + ~35m (./all update)  
8 Expected size: 8.6 GiB
9
10 |Repository |Size   |
11 |:--        |:--    |
12 |data       |1 GiB  |
13 |music      |225 MiB|
14 |darkplaces |17 MiB |
15 |netradiant |19 MiB |
16 |d0_blind_id|145 KiB|
17 |maps       |2.1 GiB|
18 |gmqcc      |3.3 MiB|
19
20     git clone https://gitlab.com/xonotic/xonotic.git
21     cd xonotic
22      ./all update -l best
23
24 After cloning the repository
25 ----------------------------
26
27 After you cloned the repository (using `git clone <url>`) you are ready to start creating a branch to start working.
28 Please check [Repository Access](Repository_Access) to make sure you checked out **all** of the repositories. `data/` for example resides in its own repository.
29
30 Compiling
31 ---------
32
33 Run `./all compile` to compile the engine and gamecode. Add -r for a faster release build without debugging symbols.
34
35 Project structure
36 -----------------
37
38 The game content can be divided into several distinct parts, like the `data/` directory, and some of its subdirectories. This is why there are several repositories, and a helper script to fetch and update them all. This is described in [Repository Access](Repository_Access) under “Working with the helper script ./all”
39
40 The current structure looks as follows:
41
42 | Directory | Repository |
43 | --------- | ---------- |
44 |`/`|git://git.xonotic.org/xonotic/xonotic.git|
45 |`/d0_blind_id`|git://git.xonotic.org/xonotic/d0_blind_id.git|
46 |`/darkplaces`|git://git.xonotic.org/xonotic/darkplaces.git|
47 |`/data/xonotic-data.pk3dir`|git://git.xonotic.org/xonotic/xonotic-data.pk3dir.git|
48 |`/data/xonotic-maps.pk3dir`|git://git.xonotic.org/xonotic/xonotic-maps.pk3dir.git|
49 |`/data/xonotic-music.pk3dir`|git://git.xonotic.org/xonotic/xonotic-music.pk3dir.git|
50 |`/data/xonotic-nexcompat.pk3dir`|git://git.xonotic.org/xonotic/xonotic-nexcompat.pk3dir.git|
51 |`/gmqcc`|git://git.xonotic.org/xonotic/gmqcc.git|
52 |`/mediasource`|git://git.xonotic.org/xonotic/mediasource.git|
53 |`/netradiant`|git://git.xonotic.org/xonotic/netradiant.git|
54 |`/netradiant-xonoticpack`|git://git.xonotic.org/xonotic/netradiant-xonoticpack.git|
55
56 When using the ssh protocol, the xonotic/ directory is skipped, so it’s just: git.xonotic.org/xonotic.git
57
58 You can still use the `data/` directory as base for the game since darkplaces now supports `.pk3dir` directories natively.
59
60 Creating a new branch
61 ---------------------
62
63 By convention, branches are usually called <yourname>/<branch>.
64 Before creating a branch, you first have to choose a base of your branch. Then you can create your branch:
65 Let’s assume your name is `me`, your branch will be called `feature1` and your base will be `master`.
66 There are several ways of creating a branch:
67 You can simply create it by doing this from the xonotic directory and selecting where to branch:
68
69     ./all branch me/feature1
70
71 This will create the branch locally and nothing else. It will not checkout the branch. You can do this now with:
72
73     git checkout me/feature1
74
75 Another possibility would be to checkout your base, and then use `git checkout -b me/feature1`. This is usually nice if you already are on your base branch because it is a single command.
76
77 In case you want to make it available publicly, the most efficient way would be to first push the base branch as your branch on the remote:
78
79     git push origin master:refs/heads/me/feature1
80     git branch --track me/feature1 origin/me/feature1
81     git checkout me/feature1
82
83 The reason for this are tracking branches.
84
85 #### Tracking branches
86
87 Whenever you are working with a branch that is available to the public, you want to know the state of your branch on the remote repository.
88 You can either do this manually by getting diffs and logs from `origin/me/feature1..me/feature1` using
89
90     git log origin/me/feature1..me/feature1
91     git diff origin/me/feature1..me/feature1
92
93 Or you make sure you have tracking branches.
94 This can be done by using `git branch —track ...` to create the branch.
95
96 #### Making a non-tracking branch a tracking branch
97
98 Most of git's magic is done in the config file. A tracking branch simple has merge information in the config. If your branch is not a tracking one and you wish to make it one, you can either push it, then remove the local version, and use `git branch —track me/feature1 origin/me/feature1` to recreate it as a tracking one, or you add the necessary config lines:
99
100     git config branch.me/feature1.remote origin
101     git config branch.me/feature1.merge refs/heads/me/feature1
102
103 Committing changes
104 ------------------
105
106 After editing the code, you need to commit your changes. Since in git all your changes are local and you usually push to the repository after you added a set of changes, it is usually a good idea to make small commits with a good commit-message, instead of committing huge chunks of changes.
107
108 Some useful commands:
109
110 -   To add new files to the index to be committed on git commit: `git add file1 [file2...]`
111 -   To commit the files which have been added using `git add`: `git commit` or `git commit -m "message"`
112 -   To commit ALL changed files (without adding new files): `git commit -a` or again: `git commit -am "message"`
113
114 In git all your changes are local. This includes your commits! If you want your branch to be updated on the remote repository, you have to push it.
115
116 -   Usually, you can push your changes doing: `git push me/feature1`
117 -   If your branch is not a tracking branch: `git push origin me/feature1` or if you have an older git version you may have to do `git push origin me/feature1:refs/heads/me/feature1`
118
119 Reverting
120 ---------
121
122 Remember that `git revert` creates a **new commit** which reverts the changes of the commit you are reverting.
123 This is important to avoid conflicts for others who pull from your branch.
124 If the change you are reverting is not yet pushed to any repository, you can also try to erase it from the history.
125
126 TODO: Add information about removing a commit from the history, and about how to remove the last commit by checkout out the previous one.
127
128 Merging and rebasing
129 --------------------
130
131 In git you have two ways of combining two branches: You can either merge them, which does exactly what its name suggests: it merges the commits together. Or you can rebase the branch.
132
133 Rebasing means that all your changes will be put at the end. This works by first collecting and removing all your changes, then replacing your branch with the base branch, then applying all your changes to it. Whenever something fails to apply you’ll be asked to fix it, and then issue a `git rebase —continue`
134
135 -   Merging master into me/feature1:
136
137         git checkout me/feature1
138         git merge master
139
140 -   Merging some other branches into me/feature1:
141
142         git checkout me/feature1
143         git merge branch1 branch2 brnach3
144
145 -   Rebasing my branch - you should only do this when the branch is not pushed to a remote repository regularly:
146
147         git checkout me/feature1
148         git rebase master
149
150     in case of conflicts, edit the conflicting files, then do:
151
152         git add conflicting_file1 [conflicting_file2...]
153         git rebase --continue
154
155 TODO...