GIT · Foundations · 10 min
Record a script as executable
Store executable permission in Git’s index, including on Windows.
Not completedYour task
Record check.sh with Git mode 100755 and commit only that permission change. Preserve the script text.
What you’re aiming for
- git ls-files --stage reports mode 100755.
- The last change is a mode change, not a content edit.
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-record-executable-bit && cd opsrung-git-record-executable-bit
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 '%s\n' 'A disposable OpsRung practice repository.' > README.txt git add -- README.txt git commit -m 'Start practice' printf '%s\n' '#!/bin/sh printf "ready\n"' > check.sh git add check.sh git update-index --chmod=-x check.sh git commit -m 'Add non-executable check script'
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
Filesystem permissions and Git’s index can differ on Windows.
Hint 2
git update-index can record the executable bit.
Hint 3
Use --chmod=+x for the tracked script, then commit.
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 ls-files --stage check.sh git show --summary HEAD git status
What you should see
- git ls-files --stage reports mode 100755.
- The last change is a mode change, not a content edit.
If your result differs: Work only in this exercise’s repository. Compare the branch, files, and history with every goal before marking complete.
Compare with one possible solution
git update-index --chmod=+x check.sh git commit -m 'Mark check script executable'
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.