Lab - Software Version Control with Git
© 2020 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 15 www.netacad.com
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: DEVASC.txt
devasc@labvm:~/labs/devnet-src/git-intro$
Step 4: Committing a File.
Now that you have staged your changes, you will need to commit them in order to let Git know you want to
start tracking those changes. Commit your staged content as a new commit snapshot by using the git
commit command. The -m message switch enables you to add a message explaining the changes you've
made. Note the number and letter combination highlighted in the output. This is the commit ID. Every commit
is identified by a unique SHA1 hash. The commit ID is the first 7 characters of the full commit hash. Your
commit ID will be different than the one displayed.
devasc@labvm:~/labs/devnet-src/git-intro$ git commit -m "Committing
DEVASC.txt to begin tracking changes"
[master (root-commit) b510f8e] Committing DEVASC.txt to begin tracking changes
1 file changed, 1 insertion(+)
create mode 100644 DEVASC.txt
devasc@labvm:~/labs/devnet-src/git-intro$
Step 5: Viewing the Commit History.
Use the git log command to show all commits in the current branch's history. By default, all commits are
made to the master branch. (Branches will be discussed later.) The first line is the commit hash with the
commit ID as first 7 characters. The file is committed to the master branch. This is followed by your name and
email address, the date of the commit and the message you included with the commit.
devasc@labvm:~/labs/devnet-src/git-intro$ git log
commit b510f8e5f9f63c97432d108a0413567552c07356 (HEAD -> master)
Date: Sat Apr 18 18:03:28 2020 +0000
Committing DEVASC.txt to begin tracking changes
devasc@labvm:~/labs/devnet-src/git-intro$
Part 4: Modifying the File and Tracking the Changes
In this part, you will modify a file, stage the file, commit the file, and verify changes in the repository.
Step 1: Modify the file.
a. Make a change to DEVASC.txt using the echo command. Be sure to use ">>" to append the existing file.
The ">" will overwrite the existing file. Use the cat command to view the modified file.
devasc@labvm:~/labs/devnet-src/git-intro$ echo "I am beginning to understand
Git!" >> DEVASC.txt
b. Use the cat command to view the modified file.
devasc@labvm:~/labs/devnet-src/git-intro$ cat DEVASC.txt
I am on my way to passing the Cisco DEVASC exam
I am beginning to understand Git!
devasc@labvm:~/labs/devnet-src/git-intro$