Skip to content

How To Use GitHub

Victor Linfield edited this page Dec 15, 2018 · 10 revisions

Working on a feature

A good first step is to make sure you have the latest version of the master branch.

git checkout master 
git pull

Next you should make a feature branch. There are two ways to create the branch and check it out:

git branch <BRANCH_NAME> 
git checkout <BRANCH_NAME>

OR

git checkout -b <BRANCH_NAME>

Where <BRANCH_NAME> is the name of your branch. You can now go ahead and make whatever changes you want to the code.

Publishing your changes to GitHub

The first thing to do is "stage" or add the files you want to commit. Do this with:

git add <FILENAMES>

Where <FILENAMES> is a list of files to be added, each separated by a space.

If you want to add all of the changed files type:

git add .

If you added a file by mistake and want to undo it, use:

git reset <FILENAMES>

The next step is to commit the changes locally. To do this, commit the files you have added:

git commit -m "<MESSAGE>"

Replace <MESSAGE> with some meaningful description of what you changed.

Next you have to publish your local changes to the git server so everyone will receive them. Simply type:

git push

If it is your first time pushing with your branch, git will tell you that the branch doesn't exist run:

git push --set-upstream origin <BRANCH_NAME>

Incorporate changes in master in your branch

As master is being updated, it is good to keep your branch up to date with it. This is especially true when you want to merge your code into master. To do this, check out master and get the latest changes:

git checkout master  
git pull

Then go back to your branch and merge master into your branch:

git checkout <Your_BRANCH>  
git merge master

Doing the merge may open a command line text editor. Type :q to quit the editor and complete the merge.

If the merge has conflicts, you will need to change the files manually to resolve the merge, then commit the changes.

Once you have merged successfully, do a git push to publish these updates.

Merging your code into master

You don't need the command line for this. Go to the "Pull Requests" section on GitHub, click "Create New Pull Request", then select the branch you wish to merge into master. Don't click the merge button as one of the software heads will review and approve your code to be merged.

  • Reviewers should be the software heads.
  • Assignees should be yourself and anyone else working on the code to be merged.
  • Labels should be chosen to reflect the type of changes.
  • Projects should be MATE 2019 Competition
  • Milestones should be the deadline for the section that the changes belong to such as control software.

Issues

Issue should be used liberally for things like the following:

  • Brainstorming and new ideas
  • Improvements to current features
  • General discussion
  • Bugs in the code

Get a fresh copy of the software on your computer

Just cd to the directory where you want the code and type:

git clone https://github.com/EasternEdgeRobotics/2019.git

OR if your using SSH

git clone git@github.com:EasternEdgeRobotics/2019.git