LEARN · FIRST PRINCIPLES
Git without the mystery
Save updates working files only
- working filesStage: select contents
- staged selectionCommit: record locally
- local commit historyPush: share commits
- GitHub-hosted repository
Save writes the local working file. Stage selects its current contents. Commit records selected contents in local history. Push shares commits with another repository, which may be on GitHub.
Connections and limits
Save changes working files. Stage copies selected content into the index. Commit records that selection locally. Push shares commits and requests a remote branch update. Later working edits are not automatically staged, committed or pushed.
Do not draw Save directly updating GitHub. Git is the history system; GitHub is one hosting service. Staging captures current content, not all future edits.
Imagine you changed the blink timing and want to record exactly what the files look like now. A file is named stored information; a project groups related files and settings. Git records versions of files and how those records connect. GitHub is an online service hosting Git projects and collaboration. You can record local Git history without GitHub or the internet.
A repository is a project with Git's recorded history and related information. The working tree is the files you currently edit. Save writes editor changes to a working file. It does not create a history record. Status tells you which files differ, which contents have been selected for a record, and which files Git does not yet track. A diff displays differences, such as a line changing from delay(1000); to delay(500);—a one-second wait becoming half a second. The diff does not apply the change; it shows it.
Sometimes you want to record only part of your current work. Staging selects contents for the next record. Git calls this selection the index. A commit records that selection as a point in local history with a message. If you stage the 500-millisecond version and then edit the file to 250 without staging again, the commit can still record 500. Stage is a selection of contents, not a promise to include all future edits.
History is the connected collection of commits. A branch is a movable name pointing to a line of work. Main is a common name for the project's shared branch. It is not a place where every unsaved edit automatically appears. A clone copies a repository and its history locally. A remote is a named connection to another repository, often on GitHub. Push shares local commits and requests a branch update at that other repository. Pull fetches history from there and integrates it into your current branch. Differences may conflict, so Pull is not guaranteed to complete with one click.
A small local example. In an already cloned practice project, save the timing change. Then inspect, select and record it. These are terminal commands, not C++ lines. A terminal is a text window; a shell is the program that reads the typed instructions. Run them from the project folder, following the club's existing Git setup. The words after git choose its action; src/main.cpp selects that file. Do not include credentials in files or commit them.
git status
git diff -- src/main.cpp
git add -- src/main.cpp
git diff --staged -- src/main.cpp
git commit -m "Adjust blink timing"
git statusThe first status shows what differs. The first diff displays unstaged file changes. add selects the current contents of that file for the next commit. The staged diff displays the selection you are about to record. commit makes the local record; -m supplies its description. The final status tells you what still differs or remains unrecorded. Commands can report setup problems or fail; read their messages. The -- marker in these file commands separates options from the file path. This sequence deliberately selects one file, rather than every change in the folder.
Sharing is another action. After reviewing the local record and confirming the intended branch and remote with the project's collaboration instructions, Push can share it. It does not upload your current working files independently of commits. Pull can bring other people's recorded work into your current branch; review uncommitted work and follow the existing workflow first. This beginner page does not prescribe a branch name, remote URL or permission to change a shared project.
Save changes a file. Commit records selected contents locally. Push shares commits. Git is the history mechanism; GitHub is one hosting service. Nothing about compiling or uploading firmware requires an automatic Git commit. Use the existing Git and GitHub guide for the next layer of precision and the project's collaboration rules.