Git log

[code language=”bash”]
git log –pretty=format:”%h%x09%an%x09%ad%x09%s”
[/code]
Adding it to the bash script

[code language=”bash”]
echo “alias gitl=’git log –pretty=format:”%h%x09%an%x09%ad%x09%s”‘” >> ~/.bashrc
source ~/.bashrc
[/code]

From now on you can type:

[code language=”bash”]
gitl
3918a7c8 Vivek Bhadra Wed Oct 23 14:02:16 2019 +0100 Integrating the esp8266 wifi module in SPRESENSE sdk.
cbce5ee6 Vivek Bhadra Tue Oct 22 13:16:11 2019 +0100 Fixes.
d4fc23c7 Vivek Bhadra Wed Oct 16 16:01:03 2019 +0100 Enhanced camera App for better user interactivity.
6cc05f93 Vivek Bhadra Wed Oct 16 13:47:02 2019 +0100 Customized for delayed capture of 1 mins.
[/code]
and see the formatted git log, change the format as you would like.

Checking your current git branch

[code language=”bash”]
git branch -av
[/code]
Add it to the .bashrc

[code language=”bash”]
echo “alias gitb=’git branch -av'” >> ~/.bashrc
source ~/.bashrc
[/code]
Type:

[code language=”bash”]
gitb
* customize_for_12_demo 3918a7c8 Integrating the esp8266 wifi module in XYZ sdk.
master ee8f2ddf Merge pull request #41 from XXX/release-v1.4.1
remotes/origin/HEAD -> origin/master
remotes/origin/auto_build_doxygen a5681292 Updated readme and only build doc from master
remotes/origin/master ee8f2ddf Merge pull request #41 from XXX/release-v1.4.1
remotes/origin/release_1.0.1 ec7f3dab Release tag XYZ_1.0.001 YYY.0.001 release.
[/code]
on the console to check the git branch you are on.

Creating a patch from multiple commits

[code language=”bash”]
git format-patch -x –stdout > patch-ddmmyyy.patch
git format-patch –ignore-space-change –ignore-space-at-eol –ignore-all-space -n –stdout > ~/patch4-LH3-18466-19092019.patch
[/code]

where n is the number of commits you want to get back.
–ignore-space-change
–ignore-space-at-eol
–ignore-all-space
the above options are self-explanatory.

How to remove untracked files in git?

  • Print out the list of files which will be removed (dry run)

[code language=”bash”]
git clean -n
[/code]

  • Delete the untracked files from the repository

[code language=”bash”]
git clean -f
[/code]

How to not display the untracked files with git status?

[code language=”bash”]
git status –untracked-files=no
[/code]

or

[code language=”bash”]

git status -uno

[/code]

Renaming a local branch in command line

switch to the branch you want to rename
[code language=”bash”]
git checkout branch-name
[/code]
Then rename it as below:
[code language=”bash”]
git branch -m new-name
[/code]

Leave a Reply