You are on page 1of 3

Lab 1

1. Initialize a new Git repository in a sandwich directory, and create the burger.txt file which
contains the list of ingredients for a burger, one ingredient per line.
steak
salad
tomato
2. Clone the repository locally on you VM.
 mkdir MyFirstRepo ; cd MyFirstRepo
 yum install -y git
 git init
 git clone http://gitlab.example.com/sandwich.git

3. Add to burger.txt
pickle
cheese
3. Check with git status the state of your repository. Your changes (adding the burger.txt file)
should be present only in the working copy.

4. Prepare burger.txt for commit with git commit –m “update” burger.txt. Use git status again to
verify that your changes have been committed.

5. Use git diff --cached to observe the differences between the index and the latest version in the
revision history (which is empty).
7. Now try the git log command to display the list of changes made in this deposit ; how many are
there? What is the number (a cryptographic hash in SHA1 format) of the last commit performed
?

8. Create some other sandwiches hot_dog.txt, ham_butter.txt. . . and / or modify the sandwich
compositions already created, by committing each modification separately. Each commit must
contain one and only one file creation or modification. Make at least 5 different changes (and
therefore 5 different commits). At each step try the following commands:
 git diff --cached after git add to observe what you will commit
9. Look again at the change history with git log and check with git status that you have
committed everything. Git offers several interfaces, graphical or not, to display the
history.

 git log

You might also like