Modify Files
Modify a File or Two
-
Open
README.md
in your text editor of choice. In this example, we will open the directory in Visual Studio Code by using the commandcode .
inside your repository.# Edit README using text editor code .
What if I don’t have Visual Studio Code?
In that case, you can use any text editor of your choice. If you’re using Windows, you can use Notepad. If you’re using Mac, you can use TextEdit. If you’re using a smart fridge, how did you get that in here? -
Add “Hello GDSC!” to line 3 of
README.md
and save the file withCtrl + S
(Mac:Cmd + S
). -
Go back to your terminal, or if you’re using Visual Studio Code, you can open the built-in terminal by pressing
Ctrl + \
(backtick). Then typegit status
. You’ll notice thatREADME.md
is now shown as not staged or committed.# Check repo status again using CLI git status
-
Add
README.md
to the staging area withgit add README.md
.# Stage README changes and check repo status again using CLI git add README.md
Can you guess what
git status
will output now?README.md
will be displayed in green text. That meansREADME.md
has been added to the staging area. -
Open
gdsc.txt
, add your name, occupation, a favorite hobby and something you dislike, save it, and stage it. You can usegit add .
to add all files in the current directory and all subsequent directories to the staging area. Then, typegit status
once more, and everything should now be in the staging area.Example
gdsc.txt
Name: Armand Occupation: Master's Student in Software Engineering at Babes-Bolyai University Hobby: Playing Valorant Dislike: CFR
# Stage all other files in repo and check repo status again using CLI git add .
-
Finally, let’s commit all of the files that are in the staging area and add a descriptive commit message:
git commit -m "Edit README.md and gdsc.txt"
. Then, typegit status
once again, which will output “nothing to commit.”# Commit repo changes again and check repo status again using CLI git commit -m "Edit README.md and gdsc.txt" git status
-
Take one last look at your commit history by typing
git log
. You should now see three entries.# Check repo commit history using CLI git log