GIT · Start here · 5 min
Make your first commit
Turn an untracked practice note into a saved snapshot.
Not completedYour task
Commit notes.txt on main. Keep its original text and leave the working tree clean.
What you’re aiming for
- One commit exists on main.
- notes.txt is tracked with its original content.
- There are no staged or unstaged changes.
1. Prepare your practice folder
Use Git 2.28 or newer. The setup commands below use a Bash-compatible shell: Git Bash on Windows, or Bash on Linux/macOS.
Create a new, empty folder for this exercise. If that name already exists, choose another new name. Continue only after you’re inside the new folder.
mkdir opsrung-git-first-commit && cd opsrung-git-first-commit
Create your repository
A repository is a folder whose history Git tracks. This creates the history locally; it does not upload anything. The branch is named main.
git init --initial-branch=main
Give practice commits a label
These two settings supply the author label for this repository only. The fictional email is not an account or login.
git config --local user.name 'Practice Learner' git config --local user.email 'practice@example.invalid'
Create the file you will save
printf writes one line, and > saves it in notes.txt. You are in a new practice folder, so this does not overwrite project files.
printf 'Practice starts here.\n' > notes.txt
You now have a repository and an untracked file. The task is to stage that file and make your first commit.
Only if your personal Git settings interfere
You can normally skip this. If a commit asks for a signing key, runs a custom hook, or changes line endings unexpectedly, these repository-local overrides keep this disposable exercise independent of those settings.
git config --local commit.gpgsign false git config --local core.autocrlf false git config --local core.hooksPath .git/practice-no-hooks
Retry the failed command afterward. These settings apply only inside this practice repository.
2. Try the task
Work toward the goal above. Start by inspecting the files or resources, then use a hint if you need one.
Hint 1
Start with git status. The file exists, but Git has not recorded it yet.
Hint 2
Staging and committing are separate operations.
Hint 3
Stage notes.txt, then commit it with a short message.
3. Review your result
Use these commands to look at your result and compare it with the goals. The website does not run or verify them.
git status git log --oneline git show HEAD:notes.txt
What you should see
- git status reports main and a clean working tree.
- git log --oneline lists one commit.
- git show HEAD:notes.txt prints: Practice starts here.
If your result differs: If notes.txt is still untracked or staged, it has not been committed yet. Commit it before marking this exercise complete.
Compare with one possible solution
git add -- notes.txt git commit -m "Save practice notes"
Other approaches are fine if you reach the same goal. Opening this solution does not mark the exercise complete.
Finished this exercise?
You decide when you’re done. Your choice is saved in this browser, and you can change it later.