Demo for Juniata's IT-342 class. Made in memorial of Stan Lee.
This lesson is to be done with at least one peer to demonstrate remote Git workflows.
On your system, please make sure you have Git installed on your system and a text editor of your choosing. Please configure your Github profile to use SSH keys.
Before starting the lessons, please load a terminal and Github. Email [email protected]
with the Github usernames of
those participating. I'll send an invite you will need to accept before assignment/merging is possible.
Repositories are self-contained. You can have one on your local and one that would be considered a "remote".
Github repositories are often remotes to local clones of the repository. By cloning, you automatically establish a connection to a remote repository.
On your system, run the following commands to clone to your local.
- Go to your home directory:
cd ~
- Clone with git:
git clone [email protected]:nerdstein/marvel-movies.git
You should now have a marvel-movies
directory.
Making issues is a critical way to collaborate on improvements to projects.
On github, perform the following steps.
- Click on the issues tab of the repository
- Click on "New Issue" button
- Describe your proposed change and save
- assign yourself an issue and note the issue number, e.g. 4
- on your local, make a new branch:
git checkout -b issue-4
where 4 is the issue number - perform the work described in the issue on your local
- commit the work:
git commit -a -m "Issue 4: provide a description of your change
- verify the name of your remote repo:
git remote -v
, you should seeorigin
- push your work to a remote branch on Github:
git push origin issue-4
- go to Github, you should see a "issue-4, compare and make pull request" message with a button
- when you have an open a pull request, assign it to your peer to review by opening the pull request and clicking the "gear" next to "assign" on the right column
- have your peer review your change through the "pull requests" tab on github
- your peer should submit a review to accept or reject changes
- once approved, your peer should merge the pull request
While this link may have delays, you should see your change at this link.
Changes can be merged in at any time in the remote repository. It is best to frequently pull changes.
When you start working on a new issue, it's best to load the most recent change to avoid any remote conflicts.
- Load the default master branch on your local:
git checkout master
- Fetch all changes from remotes:
git fetch --all
- Synchronize your local master with the remote branch:
git reset --hard origin/master
Changes to the upstream branch can happen while you are working on your changes. This often means changes cannot be merged when a pull request is made.
- Have your peer merge a change while you are working on an issue on your local system
- Commit your changes:
git commit -a -m "Issue 4: describe your work"
- Fetch all changes from remotes:
git fetch --all
- Rebase on the remote master branch:
git rebase origin/master
, note: this can be tricky if changes are made to the same files. - You may need to force push your rebase since the log of commits changed:
git push origin issue-4 --force