13 Study guide Advanced Git
| Command | Explanation | | ——– | ——– | | git commit -a | automatically stages the files that have been locally modified. New files which have not been published yet are not affected. | | git log -p | produces patch text. A patch file is used to share your local changes with others without pushing your changes to the main branch of the repo. | | git show | shows you one or more object(s) such as blobs, trees, tags, and commits. | | git diff | is similar to the Linux diff
command, and can show the changes between commits, changes between the working tree and index, changes between two trees, changes from a merge, and so on. | | git diff –staged | is an alias of $ git diff –cached, which shows all staged files compared to the named commit. | | git add -p | allows a user to interactively review patches before adding to the current commit. | | git mv | is similar to the Linux mv
command. This command can move or rename a file, directory, or symlink. | | git rm | is similar to the Linux rm
command. This command deletes or removes a file from the working tree. |
.gitignore files
.gitignore files are used to tell the git tool to intentionally ignore some files in a given Git repository. For example, this can be useful for configuration files or metadata files that a user may not want to check into the master branch.
When writing a .gitignore file, there are some specific formats which help tell Git how to read the text in the file. For example, a line starting with # is a comment; a slash / is a directory separator.
some examples of configurations included in a .gitignore
file:
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db