Git - Cheatsheet

By xngo on October 11, 2019

# Commit specific files.
    git commit -m "my notes." file1 file2 fileN
 
# List files that are deleted.
    git ls-files --deleted
 
# List files that are changed.
    git ls-files --modified
 
# List files that are added.
    git ls-files --others
 
# Add files to staging.
    # Add deleted files to staging.
        git ls-files --deleted -z | xargs -r -0 git rm
 
    # Add modified files to staging.
        git ls-files --modified -z | xargs -r -0 git add
        # or
            git add -u
 
    # Add new files to staging.
        git ls-files --others -z | xargs -r -0 git add
 
# Commit what are in staging.
    git commit -m 'Commit comment here....'
 
# List files in staging area.
    git diff --name-only --cached
 
# Unstaged all files.
    git reset HEAD -- .
# Remove a single file from staging.
    git reset HEAD -- <file>
 

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.