GitHub

GitHub is a code hosting platform that allows developers to create, store, manage, and share their code. It uses Git software, providing the distributed version control of Git plus access control, bug tracking, software feature requests, task management, continuous integration, and wikis for every project. Refer to GitHub Docs for additional GitHub documentation and tutorials.

Saving and Retrieving Code Changes

Like other cloud platforms (e.g., Google Docs), GitHub allows users to work on projects together. Please note, code changes must be manually saved. GitHub does not automatically save your work. To save changes, open the Terminal application, navigate to the cloned repository, and run the following commands, replacing "INSERT PROGRESS NOTE" with brief description of changes.

git add -A
git commit -"INSERT PROGRESS NOTE"
git push
  • git add -A : adds all your code changes to the GitHub repository

  • git commit -m"INSERT PROGRESS NOTE" : adds a note to the commit which you and your team can reference later. This note should be brief and informative, describing the purpose of your code changes.

  • git push : saves your code changes to the GitHub repository.

If multiple users are pushing code changes to your GitHub repository, make sure to retrieve or "pull" these edits before you begin making code changes. To do so, open the Terminal application, navigate to the cloned repository, and run the following command. If you have made any code changes, you will need to save them first for the pull to work.

git pull

When your are making code changes, you should git pull before making any edits. This will keep your team from encountering "merge conflicts", which can become difficult to troubleshoot. To mitigate merge conflicts, make sure to communicate with your team. Inform your team whenever you push new code changes so that everyone is always working one the most updated version of the code.

Resolving Merge Conflicts

Merge conflicts happen when you attempt to merge code branches that have competing commits. They are often caused by users making code changes without pulling first. To resolve a merge conflict, work through the following steps:

  1. Identify the location of the merge conflict.

  2. Manually edit the conflicted file from a single machine, selecting the changes you want to keep in the final merge.

  3. Push the selected changes to GitHub.

All team members should pull the corrected changes from GitHub before continuing to make code changes.

Resources

Last updated