Unix_Workbench_Solutions

My solutions to the open source book "The Unix Workbench" by Sean Kross"

View on GitHub

6.3 Getting Started with Git

6.3.2 Exercises

  1. Start a repository in a new directory.

     $ mkdir new_directory
    
     $ cd new_directory
    
     $ git init
    
  2. Create a new file in your new Git repository. Make sure Git is tracking the file and then create a new commit.

     $ touch new_file.txt
    
     $ echo "This is a new file" > new_file.txt
    
     $ git add new_file.txt
    
     $ git commit -m "Added a new file"
    
  3. Make changes to the file, and then commit these changes.

     $ echo "This is the second line in the new file" >> new_file.txt
    
     $ git add new_file.txt
    
     $ git commit -m "Edited the new file"
    
  4. Add two new files to your repository, but only commit one of them. What is the status of your repository after the commit?

     $ touch file1.txt file2.txt
    
     $ git add file1.txt
    
     $ git commit -m "Added another one file"
    
     $ git status # Output:
    
     Untracked files:
       (use "git add <file>..." to include in what will be committed)
    
         file2.txt    
    
  5. Undo the last commit, add the untracked file, and redo the commit.

     $ git reset --soft HEAD~ # or HEAD~1
        
     $ git add -A
        
     $ git commit -m "Added another two files"