/
04 - Git - Exercise 2

04 - Git - Exercise 2

Task 1 - Creating a git repo

  1. Open GitBash and navigate to your folder of choice.

  2. Create a new directory called localRepo.

  3. Navigate into this newly created directory.

  4. Turn it into a git repository by typing git init .

  5. Check that the repository has been initialised - use the ls -a command to see all the hidden files, you should now see .git folder.

  6. Create a new file in this directory - touch file1.txt .

  7. Check if git recognised any change being made - git status .

  8. Stage the file - git add .

  9. Check how the status changes.

  10. Commit your change with a sensible message : git commit -m "my first commit"

  11. Check the log : git log . Can you see the commit history?

 

Task 2 - Undoing changes

  1. Open GitBash if closed and navigate to your localRepo created above.

  2. Create another file - file2.txt.

  3. Stage it.

  4. Now un-stage it - git rm --cached file2.txt

  5. Delete the file2.txt .

  6. Change the content of the file1.txt using vi.

  7. Undo those changes by checking the file out - git checkout file1.txt .