0% found this document useful (0 votes)
16 views18 pages

Git

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

Git

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

Git essentials

git init
git clone
git status
git config
git alias
git commit
git diff
git stash
.gitignore
git tag
git blame
git clean
git revert
git reset
git rm
git rebase
git reflog
git init

It initiates new repository in the current


directory. Git creates a new directory named ‘.git’
in the specified directory.
git clone

git clone command is used to create a copy of an


existing Git repository from a remote location, from
Git servers

git clone https://github.com/example/repository.git


git status

git status provides you with information about the


current state of your git repository.

git status
git status -s
git config
This command is used to configure various
aspects of git, including information,
preferences, and repository settings.

git config --global user.name “your-name”


git config --global user.email “your-email”
git config --list
git alias
git aliases like shortcuts or nicknames for longer git
commands. it lets you create shorter, easier-to-
remember names of the commands

git config --global alias.ci commit


git config --global alias.br branch
git config --global alias.st status
git commit

git commit is used when you’ve made changes to your files


in a git repository and you’re ready to save the changes as
new version

git commit -m "Your commit message here"


git diff

git diff command is used to show the difference between


different states of your git repository, like changes
between commits, changes between the working directory
and stating area, or changes between branches.

git diff
git diff --staged
git diff <commit-1> <commit-2>
git diff <branch-1> <branch-2>
git diff <filename>
git stash

this command is used when you want to record the


current state of working directory and the index,
but want to go back to clean working directory.

git stash
git stash list
git stash apply
git stash pop
git stash clear
.git ignore

.git ignore it is a file in a git repository. it is


configuration file used git to specify intentionally
untracked files that git should ignore. this file is
particularly useful for excluding files and directories
from version control that don't want to be tracked.
git tag

this command in git is used to create, list, delete, or


verify tags. Tags are used to mark specific points in
the history. They are typically used to indicate stable
versions of software.

git tag v1.0.0


git blame
it it is tool used to determine who last modified each
line of a file, along with the commit ID and the
timestamp of the modification.

git blame <filename>


git blame --since="3 weeks ago" filename
git clean

this command in git is used to remove untracked


files from the working directory. untracked files that
are not being currently tracked by the git.

git clean
git clean -d
git clean -f
git revert
this command in git is used to undo changes made
in a specific commit or range of commits by
creating a new commit that reverses those
changes. this is a safe way to undo changes
without altering the commit history.

git revert <commit>


git revert <start>..<end>
git reset
this command used to undo changes made in the
working directory, staging area (index), commit history
.Its often used to manipulate HEAD pointer and staging
area.

git reset
git reset --hard
git reset <commit>
git reset --hard HEAD
git reset --interactive
git rm
this command in git is used to remove files from
the working directory and git index. this
command can be used to stop tracking files that
are currently being tracked by git or to remove
untracked files from the working directory.

git rm <file>
git rm '*.txt'
git rm -r <directory>
git rebase
this command is used to change the base of a
branch by applying commits from another
branch on top of it. It's commonly used to
integrate changes from one branch into another
while maintaining a clean and linear history.

git rebase main


git reflog
Reference logs, or "ref logs", record when the tips of
branches and other references were updated in the
local repository. Reflogs are useful in various Git
commands, to specify the old value of a reference.

You might also like