Simple Group Project Starting Guide for GitHub (DevMountain)
Geordyn Ader - Mentor - Dallas, TX Campus
Getting Started - Choose ONE person from your group to take care of the following steps
- Go to GitHub and click the + in the top right corner. Click New Organization.
- Give it a name - should relate to your project, obviously.
- Add email for ‘billing’ - do not worry, it’s free
- Choose the Free Plan
- It’ll take you to a new page. Now add everyone in your team onto the group (including your mentor)
- Everyone will have to accept the invitation via email/GitHub notification.
- Now, create a repository. This is where you’ll be pushing to as a group.
- Whoever creates the group needs to be sure to give admin access to each team member, including mentors. Simply go to the organization, then people, then manage access for each member.
- Last, this same person needs to create a very small file tree. The group needs to agree on the structure of folders, and naming of folders. KEEP YOUR FOLDER/FILE NAMES CONSISTENT and ORGANIZED. This will save you SO MUCH trouble down the road. The person creating the file structure can do it on the master branch and push it. NEVER work on the master branch after this again.
EACH TEAM MEMBER MUST CLONE THE PROJECT — DO NOT FORK IT!
Alright, now let's make a branch and code.
Setting Up Your Branches
Before creating a new branch, make sure you are up to date with the master branch. Simply:
$ git pull origin master
Now, this is where it gets messy. Don’t you ever, ever, ever, ever work on the master branch. Let’s refresh your memories on how to make branches.
$ git checkout -b branchName
Tip: Each branch should be made based on each feature, not page. For example, some branches could be: fbAuth, editUserInfo, addingGulp, etc.
Now, after you make a branch, it's only created locally. So, we need to make it exist on GitHub for your team members to see and for you to be able to push to it:
$ git push --set-upstream origin sameBranchName
This will make your branch visible on GitHub to other team members and sets the upstream to push to your specific branch. Double check to make sure your new branch is there by going to your organization on GitHub, then to branches.
Adding, Committing, and Pushing
If you've completed the steps above, you're ready to code on your branch now!
You add and commit your files the same way you've always done it when you’re on a branch, but:
BEFORE YOU EVER COMMIT, MAKE SURE YOU ARE ON YOUR BRANCH, NOT MASTER.
After you add and commit your files push your changes to your branch on GitHub:
$ git push origin sameBranchName
Now, if you’re ready to make a pull request in order to merge your branch's code with Master, head over to GitHub:
Your Organization >> Branches >> Your Branch >> Compare & Pull Request
NEVER MERGE YOUR OWN PULL REQUEST UNTIL SOMEONE IN YOUR GROUP APPROVES IT!
Merging Master Changes With Your Branch
Double check to make sure you are up to date with the master branch. But first, you must commit your changes on your branch. Before applying outside changes, you should get your own work in good shape and committed locally, so it will not be clobbered if there are conflicts.
# on your branch, git add $ git commit -m “blah" $ git checkout master $ git pull origin master
Now, merge your branch with the master. There could possibly be conflicts if you have not been keeping up with the master, but no worries, it’s usually nothing that can’t be fixed in a few minutes [……hopefully].
$ git checkout branchName $ git merge master
If you tried a merge which resulted in complex conflicts and want to start over, you can recover:
On your branch $ git merge --abort
When you are finished with a feature, and everything has been merged with the master branch via pull request, you should delete your branch associated with that feature locally and on GitHub to keep things clean and organized. You can delete it manually on GitHub by going to the organization then to branches, or you can delete it from GitHub by writing:
$ git push origin :BranchName
The difference from before is simply the colon :
To delete your branch locally:
$ git branch -d branchName
To FORCE branch deletion locally:
$ git branch -D branchName
- Tell your Team every time a pull request has been merged with master. Don’t let your team members fall behind Master.
- Pull often, just to be sure. Even if no one has told you about changes on master, pull anyways. It doesn’t hurt.
- There is a visual of how far behind your branch is from Master on GitHub under Branches.
- Double check with team members before merging.
- Make sure you are on a branch before you start coding. Get in the habit of checking.