Set up 8: every practice: pull, change, commit, push
Everyone who changes code does this, every practice.
Why: git keeps every saved version of the code. You can undo a mistake, share code between laptops, and get back the exact code that ran at the last event.
The loop
Section titled “The loop”1. Pull first: get the team’s newest code
Section titled “1. Pull first: get the team’s newest code”GitHub Desktop: click Fetch origin (top bar). If it changes to Pull origin, click it.
Command line:
Where: Android Studio’s Terminal tab, in the project folder (a new Terminal tab starts there). (Which folder)
git pullgit submodule updateWhy git submodule update: it puts the library at the version the project expects.
2. Change, build, test
Section titled “2. Change, build, test”Make one change at a time. Build (hammer), install (Run), and test on the robot.
3. Commit: save a snapshot each time a small change works
Section titled “3. Commit: save a snapshot each time a small change works”GitHub Desktop:
- The Changes tab lists the changed files. Untick a file you do not want.
- Type a message in Summary (bottom left).
- Click Commit to main.
Command line:
Where: the same Terminal tab, in the project folder.
git statusgit add TeamCodegit commit -m "Auto: park 2 in further left"Read what git status lists, so you commit only what you meant to.
A good message says what changed and why: Lift: high step 2400 -> 2350 (it hit the stop).
Not stuff or fix.
4. Push before you leave
Section titled “4. Push before you leave”GitHub Desktop: click Push origin.
Command line:
Where: the same Terminal tab, in the project folder.
git push
When the push is refused (rejected ... fetch first), a teammate pushed first. Pull (step 1), then push again.
Team rules
Section titled “Team rules”mainalways builds and works. Never push code that does not build.- Pull before you start.
- Commit often, one small working change at a time.
- Push before you leave. Until then, your commits are only on your laptop.
- Two people, one file: talk first (“I am changing
Tunables.java”).
Done when
Section titled “Done when”You pulled at the start, and you pushed your work at the end.
More git (branches, conflicts, undo, before an event): Git and GitHub for FTC teams.
Set up is done. Next: Pick your start: the code you start from.
Look it up: Troubleshooting: git problems.
Something wrong on this page? Tell us with a short GitHub form.