For introduction to git, please see section Git Intro
The Spartronics Programming Team uses GitHub's fork & pull request workflow. This workflow balances flexibility with productivity for the individual developers.
- Individuals have the flexibility of working on their own repos, while collaborating as a small team, such as pair programming or getting code reviews from mentors before a pull request (PR)
- Standard practice is for developers to push their local repos to their remote forks, ensuring code continuity and code backup
- Programming leads can monitor and review code contributions and ensure that the master branch is always production ready
Basic git commands and process flow is documented here. If you are new to git, please start with our Git Intro.
Start with forking the team repo on GitHub and cloning your repo on your computer.
This command is handy to stay in sync with the upstream branch:
$ git pull upstream master.
- Make changes on your local repo
- Test changes on the robot
git addthe changed filesgit committo package and document the changesgit push origin masterto send the commits to GitHub- Make a pull request at your fork's GitHub page
- Make changes as requested in the review process, and push them to GitHub
git pull upstream masterafter the pull request is accepted and merged
git status- Shows the current status of your git repository, including:
- What files you've edited (shown in red until you
git addthem) - What you've deleted (shown in red until you
git addthem) - What things are ready to be committed (shown in green)
- Whether you have any conflicts (shown in a different color)
- Whether your code has been pushed to your fork ("Your branch is up-to-date...")
- What files you've edited (shown in red until you
- Shows the current status of your git repository, including:
git add <file1> <file2>- Adds ("stages") files to the index, which is where
git commitpulls changes from - You can just use
git add srcto add every change you've made inside thesrcfolder.- Please make sure you actually intend to commit EVERYTHING you change inside that folder before you run this.
- Before moving on, it is worthwhile to use
git statusto double-check the list of files you want to add
- Adds ("stages") files to the index, which is where
git commit- Takes the changes staged by
git addand records them as a new commit - When you run this, it opens the
vieditor by default, so you can write a message for your commit. See the readme for instructions on usingvi - You can also use
git commit -m "your message in quotes here"to write a short message directly
- Takes the changes staged by
git pull- Pulls down commits from the specified remote
- Most often used like
git pull upstream master-- this means "pull themasterbranch from theupstreamremote - You need (well, you should) do this both daily and before using
git push, to ensure your changes don't cause conflicts
git push- Pushes your commits to a remote
- Most often used like
git push origin master-- "push themasterbranch toorigin" - Do this frequently to make sure your changes are backed up on GitHub
