frequently used commands¶
some git commands i frequently use but sometimes keep forgetting.
restore a file
restore to the last commit in main
restore to last commit in current branch
restore a folder
references : git-tower
pull and rebase
after resolving conflicts and add to stage
to cancel rebase process
references : git docs
relocate last commit to another branch¶
when you accidentally commit to
branch_a but actually you want to commit it in
remove created tag¶
rename a tag¶
create an tag alias with a new name
remove the old tag locally
remove the tag on the remote, with a checkout
the third argument is your remote repo. in our example,
finally, add the new tag to the remote repo. the new tag will not be added until this is done.
repeat this process in all remotes.
use ssh key to sign a commit¶
this only works with git 2.34.0 or newer and openssh 8.0 or newer.
configure git to use ssh for commit signing, and tell git which key must be used
-S flag when signing your commits:
or tell git to sign your commits automatically
use gpg to sign a commit¶
list all your keys
we need this hexadecimal value after the slash. add this value to your git config.
7DD21DBA by your hexadecimal value from the last command. to use this key in only one repo, run the last command without the
--global. when you do an commit, add the