git
git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.[1]
Documentation
- man 1 'git' [EN]
- man 1 'git-add' [EN]
- man 1 'git-checkout' [EN]
- man 1 'git-clone' [EN]
- man 1 'git-commit' [EN]
- man 1 'git-diff' [EN]
- man 1 'git-gc' [EN]
- man 1 'git-init' [EN]
- man 1 'git-log' [EN]
- man 1 'git-mv' [EN]
- man 1 'git-pull' [EN]
- man 1 'git-rm' [EN]
- man 1 'git-status' [EN]
Syntax
git [GLOBAL-PARAMETER ...] SUBCOMMAND [PARAMETER ...]
Subcommands & Parameters
- add
- Add file contents to the index.
- -n, --dry-run
- Don’t actually add the file(s), just show if they exist and/or will be ignored.
- checkout
- Switch branches or restore working tree files.
- -b BRANCH [START_POINT]
- Create a new branch named BRANCH and start it at START_POINT.
- -B BRANCH [START_POINT]
- Creates the branch BRANCH and start it at START_POINT; if it already exists, then reset it to START_POINT.
- --orphan BRANCH [START_POINT]
- Create a new orphan branch, named BRANCH, started from START_POINT and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.
- clone
- Clone a repository into a new directory.
- -b NAME, --branch NAME
- Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to NAME branch instead. In a non-bare repository, this is the branch that will be checked out.
- commit
- Record changes to the repository.
- -a, --all
- Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.
- -m MESSAGE, --message MESSAGE
- Use the given MESSAGE as the commit message. If multiple -m options are given, their values are concatenated as separate paragraphs.
- diff
- Show changes between commits, commit and working tree, etc.
- gc
- Cleanup unnecessary files and optimize the local repository.
- --aggressive
- Usually git gc runs very quickly while providing good disk space utilization and performance. This option will cause git gc to more aggressively optimize the repository at the expense of taking much more time.
- --force
- Force git gc to run even if there may be another git gc instance running on this repository.
- --keep-largest-pack
- All packs except the largest pack and those marked with a .keep files are consolidated into a single pack.
- init
- Create an empty Git repository or reinitialize an existing one.
- --bare
- Create a bare repository.
- log
- Show commit logs.
- --author=PATTERN, --committer=PATTERN
- Limit the commits output to ones with author/committer header lines that match the specified PATTERN (regular expression).
- --date=FORMAT
- Only takes effect for dates shown in human-readable format, such as when using --pretty.
- --pretty[=FORMAT], --format=FORMAT
- Pretty-print the contents of the commit logs in a given format, where FORMAT can be one of oneline, short, medium, full, fuller, email, raw, format:<string> and tformat:<string>.
- --since=DATE, --after=DATE
- Show commits more recent than a specific DATE.
- --until=DATE, --before=DATE
- Show commits older than a specific DATE.
- mv
- Move or rename a file, a directory, or a symlink.
- -f, --force
- Force renaming or moving of a file even if the target exists.
- -n, --dry-run
- Do nothing; only show what would happen.
- pull
- Fetch from and integrate with another repository or a local branch.
- rm
- Remove files from the working tree and from the index.
- -f, --force
- Override the up-to-date check.
- -n, --dry-run
- Don’t actually remove any file(s). Instead, just show if they exist in the index and would otherwise be removed by the command.
- -r
- Allow recursive removal when a leading directory name is given.
- status
- Show the working tree status.
Examples
- Showing last month’s commits
date_since="$(date '+%Y-%m-01' --date='-1 month')"
date_until="$(date '+%Y-%m-%d' --date="${date_since} +1 month -1 day")"
git log --since="${date_since}" --until="${date_until}" --author='alex' \
--pretty='format:"%cd %h %s"' --date='short'
References
- ↑ man 1 'git'