|
| 1 | +--- |
| 2 | +title: "Git: Remotes, Collaborate, Pull Requests " |
| 3 | +output: |
| 4 | + html_document: |
| 5 | + self_contained: false |
| 6 | +--- |
| 7 | + |
| 8 | +This document follows set-up from the [first hands-on](handson.html) |
| 9 | + |
| 10 | +This section introduces a variety of topics: fork, pull requests, collaborators, wikis on GitHub, Issues on GitHub, and git remotes. |
| 11 | + |
| 12 | +## Roll back |
| 13 | + |
| 14 | +## File |
| 15 | + |
| 16 | +Sometimes the easiest thing to do is grab the file (or subtext from a file) in a previous commit that is already displayed on GitHub. To do so. |
| 17 | + |
| 18 | +1. Find your repository on GitHub |
| 19 | +1. Click the "commits" tab |
| 20 | +1. Click the SHA link for the commit which has the most recent working version |
| 21 | +1. Click the filename representing the working file you want |
| 22 | +1. Click View; Raw |
| 23 | +1. Copy what you want and over-write your local repository with the previously working version |
| 24 | + |
| 25 | +## Repository |
| 26 | + |
| 27 | +<figure><figcaption>KXCD. Git: https://xkcd.com/1597/</figcaption></figure><br> |
| 28 | + |
| 29 | + |
| 30 | +## Collaborating |
| 31 | + |
| 32 | +Repositories can have collaborators which have full access to change code. Alternatively, anyone can fork a repository and make their own changes their forked copy of your public repository. The author of the changes (in the forked repository) can then initiate a "Pull Request" which enables the root repository owner to consider whether those changes will be integrated into the main repository. |
| 33 | + |
| 34 | +### Fork |
| 35 | + |
| 36 | +When you fork a repository you make a copy of that repository on GitHub. The difference between fork and clone is that clone does not make a GitHub copy and will not be eligible to submit modifications as a pull request. If you simply want to run code from another repository, clone the repository locally. |
| 37 | + |
| 38 | +If you intend to submit modifications to some other repository by issuing a Pull Request, fork the repository first. Then clone the forked repository. |
| 39 | + |
| 40 | +https://github.com/data-and-visualization/pr_hello-world |
| 41 | + |
| 42 | +1. [Source] Fork this repository |
| 43 | +1. [Partner] Clone your forked copy of the repository |
| 44 | +1. [Partner] Make some changse to your cloned [forked] repository. (e.g. add a file, edit the readme, etc.) |
| 45 | +1. [Partner] Using the git commands you've already learned: add, commit, and push the changes |
| 46 | + |
| 47 | + |
| 48 | +### Pull Requests |
| 49 | + |
| 50 | +1. [Partner] From GitHub, find the **Pull Request** tab `>` New Pull Request |
| 51 | + |
| 52 | +The act of initiating a new Pull Request will spawn a message to the original owners of the source repository. |
| 53 | + |
| 54 | +1. [Source] Go to your repository |
| 55 | +1. Merge Pull request |
| 56 | + |
| 57 | +### Collaborators |
| 58 | + |
| 59 | +To enable a collaborator (GitHub) or member (GitLab), simply edit the settings for your repository on GitHub. You collaborator can then clone the repository and use git functions just as you do. |
| 60 | + |
| 61 | +For Example, in GitHub. |
| 62 | + |
| 63 | +1. Login to the repository |
| 64 | +1. Go to the Settings |
| 65 | +1. Choose Collaborators |
| 66 | + |
| 67 | +## Wikis on GitHub |
| 68 | + |
| 69 | +The GitHub Wiki is unique to your repository. Use it to lay out a roadmap of your project. |
| 70 | + |
| 71 | +## Issues on GitHub |
| 72 | + |
| 73 | +The issues section is a good place to track bugs with your repository. You might even use this as a public todo list. |
| 74 | + |
| 75 | +## Remotes |
| 76 | + |
| 77 | +In the **terminal**, try these `git` commands. What do they mean... |
| 78 | + |
| 79 | +``` sh |
| 80 | +git branch |
| 81 | +git remote |
| 82 | +git remote -v |
| 83 | +``` |
| 84 | + |
| 85 | + |
| 86 | +### Add a Remote |
| 87 | + |
| 88 | +You can push your local repository to more than one remote social coding location... |
| 89 | + |
| 90 | +``` sh |
| 91 | +git remote add <<branch name>> <<repo location>> |
| 92 | +
|
| 93 | +# e.g. `git remote add <<branch name>> <<GitHub Repo Address>> |
| 94 | +# e.g. a GitHub Remote Address might look like this: https://github.com/data-and-visualization/mozadrella-test.git |
| 95 | +
|
| 96 | +git remote -v |
| 97 | +git push -u mirror-dvs master # u stands for *upstream* |
| 98 | +git push mirror-dvs master |
| 99 | +``` |
| 100 | +
|
| 101 | +
|
| 102 | + |
| 103 | +<!-- Notes for Next Section --> |
| 104 | +<!-- Should cover collaboration |
| 105 | +- Simplicity of the Roll-back on Social Coding sites (look at a previous version, copy/paste) |
| 106 | +- XKCD: sync-up ; If errors: save work elseswhere, delete and download a fresh copy. |
| 107 | +- pull requests |
| 108 | +- revert |
| 109 | +- reset |
| 110 | +- remotes |
| 111 | +- triggers / Webhooks |
| 112 | +- add collaborators |
| 113 | +- Organizational Accounts |
| 114 | +- wiki |
| 115 | +- issues |
| 116 | +and collaboration --> |
| 117 | + |
0 commit comments