Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 1.32 KB

File metadata and controls

50 lines (39 loc) · 1.32 KB

Git

Set user name and email

git config --global user.name "<name>"
git config --global user.email "<email>"

Handy aliases

git config --global alias.co checkout
git config --global alias.mst 'checkout master'
git config --global alias.p pull
git config --global alias.s status
git config --global alias.su 'submodule update'

Revert a commit and leave the reverted files as staged changes

git revert -n <commit>

Show number of commits per author

git shortlog -sn

# Exclude merge commits
git shortlog -sn --no-merges

# Count from a specific date
git shortlog -sn --no-merges --since "01 January 2021"

Change the author or date of some unpushed commits

# Find the hash of the oldest commit to change and start an interactive rebase from that point
git rebase -i <hash>

# In the editor that starts, change the lines you want to modify from "pick" to "edit"
# Save and close the editor

# For each commit, to change author enter
git commit --amend --author="User Name <user@email.com>" --no-edit

# For each commit, to change date/time enter
GIT_COMMITTER_DATE="Wed Oct 25 10:00:00 2023 +0200" git commit --amend --date="Wed Oct 25 10:00:00 2023 +0200" --no-edit

# Proceed to the next commit
git rebase --continue