Git - SoonerRobotics/SCR-Resources GitHub Wiki

What is Git?

Git is a version control system. The way git works is by taking snapshots (called commits) of the state of a project (called a repository, or repo for short) and assembling these snapshots into a tree structure. Branches can be made in the tree to work on features in parallel with other team members, and can also be used for good project organization. Git is a really powerful tool because you can switch to different branches to see the project state in those branches, while also being able to go back in time to see earlier versions of the project.

How we use Git

Purpose of Git
SCR uses git primarily to collaborate on software projects, however, it can be used for version control of any file. The main advantage of git when it comes to software projects is the ability for people to edit the same file separately, test their features individually, and then merge them all together.

Method we follow
Think of a git repository like a tree. We call the central branch of the tree the master branch, and this branch is composed of the most stable version of the project. We also normally make a development branch (called something like dev or develop) that branches off of master; this where the most active updates are made. These updates should each be made in what is called a "feature" branch. These are smaller branches that branch off of the development branch and are merged in once the update/feature is completed by the team member.

Git Hosting
We use github to host all of our git repositories. Other hosts include but are not limited to BitBucket, GitLab, and hosting it on your own webserver.

SCR Git Procedures

There are plenty of git cheatsheets online that will give a fuller representation of all the things you can do with git. This is to outline some of the processes that we use on a regular basis in SCR

Cloning a repository
This dowloads a git repo to your computer: git clone \[repository-url\]
or, if a project has submodules: git clone --recurse-submodules \[repository-url\]

Making a commit and sharing it with others

  1. git status - run this to see what files have changed, and which files are already staged for commit
  2. git add . (to add all files in the current directory and below) or git add \[file1\] \[file2\] \[fileN\] to add a sequence of specific files.
  3. After running git add, you should run git status again to confirm the files are the ones you want
  4. Use git diff or a separate program like gitk to see what changes were made in the files you edited
  5. Commit the files using git commit -m "your message here" -m "another line if needed" or by using git commit -p to use your terminal's default text editor.
  6. Now that your files are committed, they need to be pushed so other team members can see them. Use git push to do this

Graphical Git Clients

⚠️ **GitHub.com Fallback** ⚠️