0% found this document useful (0 votes)
45 views2 pages

GIT

The document provides instructions and examples for using basic Git commands like git init, git clone, git add, git commit, and git log. It explains how to configure user settings, add and remove files from staging, and view commit history in various formats. Filtering options for git log are also covered.

Uploaded by

Pancha Brahma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

GIT

The document provides instructions and examples for using basic Git commands like git init, git clone, git add, git commit, and git log. It explains how to configure user settings, add and remove files from staging, and view commit history in various formats. Filtering options for git log are also covered.

Uploaded by

Pancha Brahma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

git init

Turn an existing directory into a git repository

git clone [url]


Clone (download) a repository that already exists on

Configure tooling
Configure user information for all local repositories
$ git config --global color.ui auto

Enables helpful colorization of command line output


$ git config --global user.email "[email address]"

Sets the email you want attached to your commit transactions


$ git config --global user.name "[name]"

The .gitignore file


Sometimes it may be a good idea to exclude files from being
tracked with Git. This is typically done in a special file named
.gitignore . You can find helpful templates for .gitignore
files at github.com/github/gitignore.

git add [file]: Adds a single file to the staging area.


git add .: Adds all untracked and modified files in the current directory and
subdirectories to the staging area.
git add -A: Adds all untracked and modified files in the current repository
(including submodules) to the staging area.

git add -p: Adds files interactively, prompting you for confirmation on each file.
git add -u: Updates tracked files in the staging area to match the working
directory (useful for quick changes).
git add -N: Adds a file as it is, even if it has been modified by other branches.
git add --patch: Stages specific parts of a file using patch selection.

git status: Shows which files are untracked, modified, or staged.

git add myfile.txt


git commit -m "Fixed a bug in myfile.txt"

Unstaging Files:

git reset HEAD [file]: Unstages a file from the staging area without affecting the
working directory.
git rm [file]: Removes a file from the staging area and the working directory (be
careful!).

Git Logs -
Basic Usage:
git log: Shows the commit history of the current branch, starting with the most
recent.
git log -n [number]: Limits the displayed commits to the last number.
git log --oneline: Presents each commit on a single line, offering a compact
overview.
git log --graph: Visualizes the commit relationships with a helpful branch diagram.
git log --decorate: Adds branch and tag information to each commit.

Filtering Commits:
git log --author [name]: Shows only commits made by a specific author.
git log --since [date]: Displays commits made after a particular date.
git log --until [date]: Shows commits made before a specific date.

Interactive Exploration:
git log -p: Review commit changes interactively, allowing patch selection.
git log --follow [file]: Track how a specific file has changed across commits.

Beyond the Basics:


git log --all: Shows all branches' commits (not just the current one).
git log --grep [pattern]: Searches commit messages for a specific keyword.
git log --count: Counts the number of commits with various filters applied.

You might also like