Lesson 3
Discovering your Paths
Chapter 5: Making a git commit
Git add and commit
Now, let us update the repo to incorporate the latest changes.
Remember the workflow! The process of updating any changes to a repo is
git add
git commit
First, check the status of your Git repo (you do remember how by now?)
user@MACHINE:~/robot$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: main.py
no changes added to commit (use "git add" and/or "git commit -a")
You can see now that main.py
is now marked as modified
.
Let us now stage the file. There are two ways to add a modified file.
git add main.py
as done previouslygit add -u
will stage all updated/modified files
I will go with the second version in the example below.
user@MACHINE:~/robot$ git add -u
user@MACHINE:~/robot$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: main.py
You can see that main.py
is ready to be committed.
So go ahead and commit the file.
user@MACHINE:~/robot$ git commit -m "Updated robot program to read in coordinates, clip the coordinates to be between 0-9, and print out the robot's coordinates and quadrant."
[master 9ec62f0] Updated robot program to read in coordinates, clip the coordinates to be between 0-9, and print out the robot's coordinates and quadrant.
1 file changed, 35 insertions(+)
And a final check:
user@MACHINE:~/robot$ git status
On branch master
nothing to commit, working tree clean
Great! You have updated your code in the repo!