DEV Community

Heru Hartanto
Heru Hartanto

Posted on

Some git command that you might never use it yet

As a developer we depend on git for our work, we might know and familiar with some of git command such as git init git push git commit git clone and bunch of other git command, but here I share you some git command that might be useful for you and I think some of you never use it before.

1 Switch to previous branch

you can use git checkout - to switching from your current branch to previous branch, this command will make your work easier when working in multiple branch

git branch
    development
    *main

git checkout -
    *development
    main

git checkout - 
    development
    *main
Enter fullscreen mode Exit fullscreen mode

2 Show manual page

If you forgot git command that you want, at least you have to remember this command as a life savior git help everyday, this command will show you manual page in minimum set format that will help with you, but if you want a full tutorial introduction, you can use git help tutorial command

3 Autocorrect

If you put this configuration git config --global help.autocorrect 10, Git will automatically within 1 second (number 10 in the last configuration line mean 1 seconds) running correct command if developer make a mistake

git config --global help.autocorrect 10
git stats 
    WARNING: You called a Git command named 'stats', which does not exist.
    Continuing in 1.0 seconds, assuming that you meant 'status'.
    --- then running git status command
Enter fullscreen mode Exit fullscreen mode

to deactivate this configuration use this command git config --global help.autocorrect 0

4 Show file content inside a branch

to preview content of a file in other branch you can simply use this command git show <branch>:<path/to/file>

git show development:README.md
    --- This is content README.md from branch development 
git show main:README.md
    --- This is content README.md from branch main 
Enter fullscreen mode Exit fullscreen mode

5 Show graphical Alternative git commit

Git command git citool, will give you a graphical interface to review modified files, stage them , put commit message and record new commit onto the current branch (git-gui required)

Top comments (2)

Collapse
 
davidcedres profile image
David

Thanks, bro, I did not know some of those, the last one requires one to install git-gui though, it does not work just like that.

Collapse
 
elukuro profile image
Heru Hartanto

Thanks for your comment, really appreciate 👍