0% found this document useful (0 votes)
16 views

Section 2 - Exercises

The document provides instructions for creating snapshots in Git. It lists 10 steps: 1) Initialize a repository and add two files, 2) View the status, 3) Stage both files, 4) View the staged changes, 5) Create an initial commit, 6) View the commit log, 7) View the last commit, 8) Update and view changes to a file, 9) Stage the updated file, and 10) Unstage the file. Sample commands are provided for each step.

Uploaded by

nebojsakg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Section 2 - Exercises

The document provides instructions for creating snapshots in Git. It lists 10 steps: 1) Initialize a repository and add two files, 2) View the status, 3) Stage both files, 4) View the staged changes, 5) Create an initial commit, 6) View the commit log, 7) View the last commit, 8) Update and view changes to a file, 9) Stage the updated file, and 10) Unstage the file. Sample commands are provided for each step.

Uploaded by

nebojsakg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Exercises

Creating Snapshots

1- Initialize a new repository. Add two files in your working directory.

2- View the status of the working directory and the staging area.

3- Stage both files.

4- View the changes in the staging area.

5- Create a commit.

6- View the list of commits.

7- View the content of the last commit.

8- Update one of the files. View the changes in the working directory.

9- Stage the changes.

10- Unstage the file.


Solutions
1- Initialize a new repository. Add two text files in your working directory.

git init
echo hello > file1.txt
echo hello > file2.txt

2- View the status of the working directory and the staging area.

git status
git status -s

3- Stage both files.

git add .

4- View the changes in the staging area.

git diff --staged

5- Create a commit.

git commit -m “Initial commit.”

6- View the list of commits.

git log

7- View the content of the last commit.

git show HEAD


8- Update one of the files. View the changes in the working directory.

echo world >> file1.txt


git diff

9- Stage the changes.

git add file1.txt

10- Unstage the file.

git restore --staged file1.txt

You might also like