You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now the project is growing, and some colleagues want to work on the code together. Without Git, this would be a slow process, as only one of you can work on the code at a time. Otherwise, it would be difficult to combine the changes.
158
+
159
+
With Git, however, code collaboration can work very efficiently. This is achieved by branching, merging and pull requests.
160
+
161
+
### Editing on a new branch
162
+
163
+
As explained in Chapter 3 and 5, the purpose of *branches* is to separate different strands of work.
164
+
165
+
Here for example, while your colleague will write some hypothesis tests on the data, you would like to make more plots to visualize data. So, before coding, you create and checkout a branch `visualization`.
166
+
167
+
> *Checkout* simply means making this the active branch, so that the following edits will be made on this branch.
168
+
169
+
In GitHub Desktop, click the branch box on the top banner, and click new branch.
After switching, the active branch is now `visualization` which can be seen on the top banner.
178
+
179
+
Alternatively, in PyCharm, create the new branch from the Git menu:
180
+
181
+

182
+
183
+
To verify the active branch, look for the Git symbol at the bottom of the screen. Most IDEs have a similar display.
184
+
185
+

186
+
187
+
Now you can modify the code, without the need to worry about what your colleague is doing. After some hard work in coding, you can stage, commit and push as usual. Everything is saved on the new `visualization` branch.
188
+
189
+
### Merging and pull requests
190
+
191
+
When you think you have finished all the codes related to `visualization`, you will want to *merge* this branch back to the base branch (in our case `master`), so that collaborators and users will be able to see and use these codes by default.
192
+
193
+
To do this, we first open a *pull request*.
194
+
195
+
Go to the repository webpage on GitHub, and click on the "Pull requests" tab. GitHub likely realizes that you are opening the pull request for the most recent branch, `visualization`. Click the green "Compare & pull request" button.
0 commit comments