There are a few common workflows you should be able to follow in order to work in this code repository for this class. For a more in-depth (and well-written!) explanation of the things below, I would recommend http://rogerdudler.github.io/git-guide/.
The upstream remote repository at tshelburne/csci-e39 will be regularly updated with bug fixes, improvements, features, etc. as time progresses. When those updates are made, you want to make sure you have the changes on your machine so that you are always working from the latest codebase.
git remote -vwill show you a list of all remote repositories- Ensure you see the following in the list: upstream git@github.com:tshelburne/csci-e39.git (fetch) upstream git@github.com:tshelburne/csci-e39.git (push)
- if not, run
git remote add upstream git@github.com:tshelburne/csci-e39.git
git pull upstream masterwill pull the latest changes frommaster
In git, everything change you make is represented as a "delta", or a set of differences between the latest committed code and whatever changes you've made. When you are ready to start making changes, you always want to work from a "branch" - this isolates your set of changes so that you can be working on multiple updates without them blocking the others.
git checkout masterand pull the latest code as detailed above
masteris the conventional name for the branch that is considered the source of truth for the most current state of the code- for the purposes of this class, you should always base a new branch for working
off of
master
git checkout -b [new branch name]will create a new branch with the given name, based off of the branch you have checked out when you run the command (in this case,master)- Make any changes needed and follow the steps below to save your changes.
When you make updates to code on your machine, eventually you will want to officially add those changes as part of the code history. Committing some changeset to history is called making a "commit".
git statuswill show you all of the changes that have been made since the last commitgit add [space-separated directories / files]will "stage" files for the next commitgit statuswill show you all the changes that will be committedgit commit -m '[a useful message to describe the changeset]'will create a new commit with the stage changesgit statuswill show that the staged changes are now gone, and only changes pending being staged remain
Once you have committed code on your machine, you want to preserve those changes on your "remote" version of the repository. In order to do that, you will push those changes to your fork.
git remote -v- Ensure you see the following in the list:
origin git@github.com:[your account name]/csci-e39.git (fetch)
origin git@github.com:[your account name]/csci-e39.git (push)
- if not, run
git remote add origin git@github.com:[your account name]/csci-e39.git
- if not, run
git push origin [current branch name]will copy the latest changes to a branch with the same name on your fork
For most use-cases in this class, we won't actually be merging student code into the upstream repository, but instead using Pull Requests for education and preparation for working on a real software team. However, if you find a bug or want to submit an improvement, you can always update the code and help us out!
- In the Github UI, click on the Pull Requests tab
- Click "New Pull Request"
- Click "Compare across forks"
- Select your fork in the "Head fork: " dropdown
- Select the branch in the "compare" dropdown
- Click "Create Pull Request"
- Update the Title and Description as appropriate
- Click "Create Pull Request"