Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for My list of useful git commands
Theodore Karropoulos
Theodore Karropoulos

Posted on

     

My list of useful git commands

As all those of us involved in the field of Computer Science know or should know, Git is by far the most widely used modern version control system in the world today. We utilized it in our everyday routine to keep track of our code changes and helps us to work with other developers simultaneously and independently.

Although modern IDE and various tools provided by GitHub, Atlassian and other provide us an easy to use way to perform many git commands nothing compares to the power a terminal provides. Bellow you can find a list of my top git commands.

Rename latest's commit message

# This will pop up an editor window allowing us to pass the new commit messagegit commit -amend # This will not pop up the editorgit commit -amend -m "Your new commit message"
Enter fullscreen modeExit fullscreen mode

Add file(s) into the latest commit. This requires that last change is not yet pushed into remote

# Add the filegit add the_file_you_want_to_add# Amend without changing commit messagegit commit --amend --no-edit
Enter fullscreen modeExit fullscreen mode

Reset to specific commit hash and discard any changes since that hash

git reset --hard <commit-hash>
Enter fullscreen modeExit fullscreen mode

Apply a commit from one branch to another

git cherry-pick <commit-hash>
Enter fullscreen modeExit fullscreen mode

Show commit logs and limit the output

git log -n <number># example git log -n 3# orgit log -<number># example git log -3
Enter fullscreen modeExit fullscreen mode

If you are aware of any useful / useful git command and want to share it please do not hesitate to leave a comment!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Hello I am Theodoros, am a Software engineer with passion on new technologies, basketball and sports in general!
  • Location
    Greece
  • Work
    Senior Software Engineer
  • Joined

More fromTheodore Karropoulos

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp