upcoming:
- cherry-picking
- force-with-lease
- squash
initialize empty git repo
git init <repo-name>
push repo to remote:
git remote add origin <repo-url>
git push origin master
clone repo locally
git clone <repo-url>
configuration
git config --global user.email "[email protected]"
git config --global user.name "user"
repository status
git status
specific filechanges
git diff <file-name>
get quick overview of last repo change
git log --oneline
undo changes
git revert <git-hash>
add file to staging area
git add <filename>
commit changes to repo
git commit -m '<commit-message>'
push changes to remote server
git push
get latest changes from remote
git pull
ignore files and dirs by adding their relative paths to the following file
.gitignore
create new branch
git checkout -B '<new-branch-name>'
delete branch
git branch -D '<branch-to-delete>'
upcoming: rebase
e.g. for the src
dir,
git whatchanged --since="last Sunday" -p -- src
git pull --rebase origin main
git log
git push --force
#!/usr/local/bin/bash
# prerequisites:
# all tags deleted
# main branch is the only branch that exists
: '
git checkout --orphan last
git add -A
git commit -am "feat: rewrite git history" --no-verify
git branch -D main
git branch -m main
git push -f origin main -v
cd .git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
# check size:
du -hs .
du -hs .git
'