blob: 1d7231a9ba491174d6a20ba0f1c7f92a2d80fc2a [file] [log] [blame]
John DeNisco06dcd452018-07-26 12:45:10 -04001.. _pushingapatch:
2
3=================
4Github Repository
5=================
6
John DeNisco758dc462018-08-13 17:00:06 -04007**The github repository is only being used as a source for readthedocs.**
8**There should be no reason for the typical developer to use this repository.**
9**It should only be used by a document developer.**
John DeNisco06dcd452018-07-26 12:45:10 -040010
11Overview
12________
13
14This section will cover how to fork your own branch of the `fdioDocs/vpp-docs <https://github.com/fdioDocs/vpp-docs>`_ repository, clone that repo locally to your computer, make changes to it, and how to issue a pull request when you want your changes to be reflected on the main repo.
15
16.. toctree::
17
18Forking your own branch
19_______________________
20
21In your browser, navigate to the repo you want to branch off of. In this case, the `fdioDocs/vpp-docs <https://github.com/fdioDocs/vpp-docs>`_ repo. At the top right of the page you should see this:
22
23.. figure:: /_images/ForkButtons.png
24 :alt: Figure: Repository options on Github
25 :scale: 50%
26 :align: right
27
28|
29|
30|
31
32Click on "Fork", and then a pop-up should appear where you should then click your Github username. Once this is done, it should automatically take you to the Github page where your new branch is located, just like in the image below.
33
34.. figure:: /_images/usernameFork.png
35 :alt: Figure: Your own branch of the main repo on Github
36 :scale: 35%
37 :align: center
38
39
40Now your **own branch** can be **cloned** to your computer using the URL (https://github.com/YOURUSERNAME/vpp-docs) of the Github page where your branch is located.
41
42
43Creating a local repository
44___________________________
45
46Now that you have your own branch of the main repository on Github, you can store it locally on your computer. In your shell, navigate to the directory where you want to store your branch/repo. Then execute:
47
48.. code-block:: console
49
50 $ git clone https://github.com/YOURUSERNAME/vpp-docs
51
52This will create a directory on your computer named **vpp-docs**, the name of the repo.
53
54Now that your branch is on your computer, you can modify and build files however you wish.
55
56If you are not on the master branch, move to it.
57
58.. code-block:: console
59
60 $ git checkout master
61
62
63Keeping your files in sync with the main repo
64_____________________________________________
65
66The following talks about remote branches, but keep in mind that there are currently *two* branches, your local "master" branch (on your computer), and your remote "origin or origin/master" branch (the one you created using "Fork" on the Github website).
67
68You can view your *remote* repositories with:
69
70.. code-block:: console
71
72 $ git remote -v
73
74At this point, you may only see the remote branch that you cloned from.
75
76.. code-block:: console
77
78 Macintosh:docs Andrew$ git remote -v
79 origin https://github.com/a-olechtchouk/vpp-docs (fetch)
80 origin https://github.com/a-olechtchouk/vpp-docs (push)
81
82Now you want to create a new remote repository of the main vpp-docs repo (naming it upstream).
83
84.. code-block:: console
85
86 $ git remote add upstream https://github.com/fdioDocs/vpp-docs
87
88
89You can verify that you have added a remote repo using the previous **git remote -v** command.
90
91.. code-block:: console
92
93 $ git remote -v
94 origin https://github.com/a-olechtchouk/vpp-docs (fetch)
95 origin https://github.com/a-olechtchouk/vpp-docs (push)
96 upstream https://github.com/fdioDocs/vpp-docs (fetch)
97 upstream https://github.com/fdioDocs/vpp-docs (push)
98
99
100If there have been any changes to files in the main repo (hopefully not the same files you were working on!), you want to make sure your local branch is in sync with them.
101
102To do so, fetch any changes that the main repo has made, and then merge them into your local master branch using:
103
104.. code-block:: console
105
106 $ git fetch upstream
107 $ git merge upstream/master
108
109
110.. note:: **This is optional, so don't do these commands if you just want one local branch!!!**
111
112 You may want to have multiple branches, where each branch has its own different features, allowing you to have multiple pull requests out at a time. To create a new local branch:
113
114.. code-block:: shell
115
116 $ git checkout -b cleanup-01
117 $ git branch
118 * cleanup-01
119 master
120 overview
121
122 Now you can redo the previous steps for "Keeping your files in sync with the main repo" for your newly created local branch, and then depending on which branch you want to send out a pull reqest for, proceed below.
123
124
125Pushing to your branch
126______________________
127
128Now that your files are in sync, you want to add modified files, commit, and push them from *your local branch* to your *personal remote branch* (not the main fdioDocs repo).
129
130To check the status of your files, run:
131
132.. code-block:: console
133
134 $ git status
135
136
137In the output example below, I deleted gettingsources.rst, made changes to index.rst and pushingapatch.rst, and have created a new file called buildingrst.rst.
138
139.. code-block:: console
140
141 Macintosh:docs Andrew$ git status
142 On branch master
143 Your branch is up-to-date with 'origin/master'.
144 Changes to be committed:
145 (use "git reset HEAD <file>..." to unstage)
146
147 deleted: tasks/writingdocs/gettingsources.rst
148
149 Changes not staged for commit:
150 (use "git add <file>..." to update what will be committed)
151 (use "git checkout -- <file>..." to discard changes in working directory)
152
153 modified: tasks/writingdocs/index.rst
154 modified: tasks/writingdocs/pushingapatch.rst
155
156 Untracked files:
157 (use "git add <file>..." to include in what will be committed)
158
159 tasks/writingdocs/buildingrst.rst
160
161
162
163To add files (use **git add -A** to add all modified files):
164
165.. code-block:: console
166
167 $ git add FILENAME1 FILENAME2
168
169Commit and push using:
170
171.. code-block:: console
172
173 $ git commit -m 'A descriptive commit message for two files.'
174
175Push your changes for the branch where your changes were made
176
177.. code-block:: console
178
179 $ git push origin <branch name>
180
181Here, your personal remote branch is "origin" and your local branch is "master".
182
183.. note::
184
185 Using **git commit** after adding your files saves a "Snapshot" of them, so it's very hard to lose your work if you *commit often*.
186
187
188
189Initiating a pull request (Code review)
190_______________________________________
191
192Once you've pushed your changes to your remote branch, go to your remote branch on Github (https://github.com/YOURUSERNAME/vpp-docs), and click on "New pull request".
193
194.. figure:: /_images/issuePullReq.png
195 :alt: Figure: Your own branch of the main repo on Github
196 :scale: 35%
197 :align: center
198
199This will bring you to a "Comparing changes" page. Click "Create new pull request".
200
201.. figure:: /_images/createNewPullReq.png
202 :scale: 35%
203 :align: left
204
205|
206|
207|
208
209Which will open up text fields to add information to your pull request.
210
211.. figure:: /_images/examplePullReq.png
212 :scale: 35%
213 :align: center
214
215
216 Then finally click "Create pull request" to complete the pull request.
217
218Your documents will be reviewed. To this same branch make the changes requested from the review and then push your new changes. There is no need to create another pull request.
219
220.. code-block:: console
221
222 $ git commit -m 'A descriptive commit message for the new changes'
223 $ git push origin <branch name>
224
225
226Additional Git commands
227_______________________
228
229You may find some of these Git commands useful:
230
231Use **git diff** to quickly show the file changes and repo differences of your commits.
232
233Use **git rm FILENAME** to stop tracking a file and to remove it from your remote branch and local directory. Use flag **-r** to remove folders/directories. E.g (**git rm -r oldfolder**)
234
235
236.. _fdioDocs: https://github.com/fdioDocs/vpp-docs
237