GIT · Foundations · 5 min
Stage only the release change
Prepare one change without including an unfinished draft.
Not completedYour task
Stage release.txt, but leave the edited draft.txt unstaged. Do not commit yet.
What you’re aiming for
- Only release.txt is in the staging area.
- draft.txt keeps its unfinished edit in the working tree.
- No new commit has been created.
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-stage-one-file && cd opsrung-git-stage-one-file
Run these setup commands in that folder:
git init --initial-branch=main git config --local user.name 'Practice Learner' git config --local user.email 'practice@example.invalid' printf 'Version: 1\n' > release.txt printf 'Draft only.\n' > draft.txt git add . git commit -m 'Initial release files' printf 'Version: 2\n' > release.txt printf 'Unfinished draft.\n' > draft.txt
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
Use git diff to inspect working-tree changes and git diff --staged to inspect the next snapshot.
Hint 2
git add . would include the draft too.
Hint 3
Name release.txt explicitly when staging.
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 diff --staged --name-only git diff --name-only git log --oneline
What you should see
- git diff --staged --name-only prints only release.txt.
- git diff --name-only prints draft.txt; its unfinished edit is still there.
- git log --oneline still lists only the initial commit.
If your result differs: If both files are staged, unstage draft.txt without discarding its edit. This task stops before creating a commit.
Compare with one possible solution
git add -- release.txt
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.