28 Git Commands to Speed Up Your Work
Git, an efficient and open-source distributed version control system, is crafted to manage projects, ranging from small to very large, with speed and freedom.
In this blog , you will know the simple hacks to speed up your work..
If You don’t have git you can install git from the following link: https://git-scm.com/downloads
Set up and Initialize
# set a name
git config --global user.name “[firstname lastname]”
# set an email
git config --global user.email “[valid-email]”
# Initialize a repo
git init
# Get an existing repo
git clone [url]
Staging and snapshot
# show modified files in working directory, staged for your next commit
git status
# add a file
git add [file]
# unstage a file
git reset file name
# diff of what is changed
git diff
# commit your staged content as a new commit snapshot
git commit -m "message"
Branch & Merge
# list your branches
git branch
# create a new branch
git branch branchname
# switch to another branch and check it out into your working directory
git checkout
# merge the specified branch’s history into the current one
git merge [branch]
# show all commits
git log
Inspect and Compare
# show the commits on branchA that are not on branchB
git log branchB..branchA
# show the commits that changed file
git log --follow [file]
# show the diff of what is in branchA that is not in branchB
git diff branchB...branchA
# show any object in Git in human-readable format
git show [SHA]
Share and Update
# add a git URL as an alias
git remote add [alias] [url]
# fetch all the branches from that Git remote
git fetch [alias]
# merge a remote branch into your current branch to bring it up to date
git merge [alias]/[branch]
# Transmit local branch commits to the remote repository branch
git push [alias] [branch]
# fetch and merge any commits from the tracking remote branch
git pull
Tracking your path changes
# delete the file from project
git rm [file]
# change an existing file path
git mv [existing-path] [new-path]
# show all commit logs with indication
git log --stat -M
Rewrite History
# apply any commits of current branch
git rebase [branch]
# clear staging area, rewrite working tree
git reset --hard [commit]