Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
3 views1 page

Git Notes

Uploaded by

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

Git Notes

Uploaded by

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

Stages in git:

 Untracked
 Added/Staged
 Committed

git status -s : will give you the status of your current staged and unstaged files (not committed files,
except committed files will be visible by this if the committed files are modified)

git log --oneline : returns the current status of current savepoints(commits)

create a .gitignore file and inside it whatever filename you write, will be automatically ignore all
those files

git reset --hard HEAD~n : will unstage changes, discard changes of ‘n’ steps backwards, effectively
removing everything from the specified commit onwards.

git reset --soft <commit_id>: Only moves the branch's HEAD, but keeps the changes from the
removed commits in the staging area.

git reset --mixed <commit_id>: Moves HEAD and unstages the changes, but keeps them in the
working directory.

git reset <file>: Unstages a single file, keeping the changes in the working directory.

git log: shows complete details of all commits made in the repo, from latest to oldest

 git log --online: will display the commit history with each commit on a single line, showing a
shortened commit hash and the commit message. This is a concise way to view the history,
especially when dealing with a large number of commits

git branch branch_name : creates a branch

git branch: lists the branch in the repo

git switch branch_name : switches to specified branch

git merge branch_name : merges the specified branch

git branch -d branch_name : deletes the specified branch, usually used when data in the specified
branch has been merged so the branch is of no use.

git switch -C branch_name : creates and switches to the created branch in a single command

git stash: when making changes to a branch but not committing it, git asks you to either delete or
save the change in a draft (stash)

git stash apply: applies the changes in the stash to the current branch

You might also like