Skip to content

Git and GitHub

Ben edited this page Nov 21, 2022 · 1 revision

Copy the Preseason repository URL

Make sure Mr. Z or another Programming Mentor has added you to the Members team within GitHub. Anyone can clone our repositories, but only members of Members can push commits and open Pull Requests.

  1. Open a web browser to https://github.com/hackbots-3414
  2. Locate and click into the 20xx-Preseason repository for your year
  3. Look for the big green <> Code button and click it
  4. Verify the HTTPS tab is highlighted, then click the double rectangle (copy) button to copy the repository's URL into your copy buffer

Clone the repo with Git Bash (or git on Linux and Mac)

  1. Open Git Bash
  2. Get to your work folder. At the prompt, type: cd ~/code/your_folder replacing your_folder with your actual folder name (e.g. mrZ)
  3. Clone the Preseason git repository by typing: git clone _url_ replacing _url_ by right-click (or shift-insert) pasting the URL you copied earlier
  4. Change directory to your newly-cloned repo directory: cd 20xx-Preseason replacing 20xx-Preseason with the correct directory name. Note that you may only need to type cd <tab> if you just created your personal code folder.

Get to know git

When you cloned the repository (repo for short), you got a complete copy of the remote (in GitHub). In class, we'll have some example tasks to help you get familiar with using git for versioning files and working as a team.

Crucial commands:

  • Create a new branch (run this before starting a new feature or defect fix:) git checkout -b _your_name_feature_name_ replacing _your_name_ with your name and _feature_name_ with something describing your feature / fix
  • Stage your code in prep for a commit: git add _file_ replacing _file_ with the path or file you wish to stage
  • Commit your code: git commit -m "comment about the change" using a comment that will help you or someone else know what you did between the ""
  • Push all your commits to GitHub since your last push: git push (note that git may complain about your branch needing to be registered, if it does, copy, paste, and run the command it tells you to, this will only need to be done once)
  • Refresh your git repo: git fetch

TODO: merge and pull TODO: Pull request

Clone this wiki locally