Saturday 28 December 2019

Git Command Line as easy as possible

Git Status
git status
git status -- short

Manipulate the Changes
git add file_name  >> adds the file file to the stage section
git restore file_name >> discards changes to the file
git restore --staged file_name >> removes the file from the stage section

Inspecting the diffs
git diff . >> displays the not-staged changes in your working tree
git diff --staged >> displays the staged changes
git diff dev >> displays changes between the working tree and the dev branch. You might use a commit hash or tag instead.
git diff master..dev >>displays changes between the branches master and dev

Committing
git commit -m 'Commit message'
git config --global core.editor your-editor-executable-path

Switch
The switch command can be used to switch between branches.
git switch branch-name >> switches to a branch-name branch
git switch -b abc >> creates branch abc and switches to it
git switch - >> switches you to the previous branch
git checkout [branch_name] >> works as a switch but can also move HEAD to any commit/tag as well

Branches
git branch >>> returns a list of the local branches.
Use -r to list only remote branches or -a to get them all
git branch abc >>> creates abc branch
git branch -d abc >>> deletes abc if already merged.
If not, use -D to force deletion.

Log Results
git log >>> to see the commits’ history.
git log -p >>>Display the changes alongside the commit description:
git log -2 >>> display two recent commits
git log branch-name  >>>Display log for a specific branch/revision:
Filter log for a specific file(s) only (glob pattern applies here):
git log *.js # or git log branch-name:*.js
Filter commits by the author (accepts partial name):
git log --author saurabh
Filter by date:
git log --since 2019-10-01
Filter by date using dynamic date ranges (days, weeks, months, years):
git log --since 2months --until 1week

Thanks
Saurabh Sharma

No comments:

Post a Comment

Build a Custom Kernel Module for Android

Hi Guys!!!Hope you are doing well !!!. Today I will describe how you can write a custom kernel module(Hello world) for Android and load it a...