DEV Community

Discussion on: Essential git commands

Collapse
 
bravemaster619 profile image
bravemaster619

Here are more practical ones(IMHO):

  • Change the last commit message
    git commit --amend

  • Revert last unpushed commit
    git reset HEAD~1 --soft

  • Show log one line
    git log --oneline
    Press q to exit

  • Delete a local branch
    git branch -d <BRANCH NAME>
    Ignore push and merge status and force delete:
    git branch -D <BRANCH NAME>

  • Delete a remote branch
    git push <REPOSITORY REF> --delete <BRANCH NAME>
    example:
    git push origin --delete beta-1.0.0

    If branch ref is equal to a tag ref:
    git push <REPOSTIORY REF> :refs/heads/<BRANCH NAME>
    example:
    git push origin :refs/heads/beta-1.0.0

Collapse
 
rokokorag profile image
Rodrigo Acevedo

And

  • Get all log graphically

git log --all --graph --oneline

  • Get status summary

git status -s

Collapse
 
iamphytan profile image
Damien LaRocque • Edited

And

  • Create a new branch and checkout at the same time

git checkout -b <new-branch-name>

Collapse
 
bravemaster619 profile image
bravemaster619

ty!