Version control
Version control (also known as revision control, source control, or source code management) is a class of systems responsible for managing changes to computer programs, documents, large web sites, or other collections of information.
The concept of backing up your “data” iteratively, so you can roll-back to specific versions as needed. At the most basic level, version control could be achieved by making a “.zip” of your data every day.
Applications
Git
Git is just the most popular version control app today. It’s not the only one.
Also, Git != Github. Git is the application. Github.com is a website that hosts code and allows developers to work together on code (and it happens to use Git)
To clone a massive repo:
$ git clone –no-tags –depth 1 <repoURI>
$ git fetch –unshallow
Alternativ, just one folder/ file:
$ git clone –filter=tree:0 –depth 1 <repoURI>
$ cd <repoDIR>
$ git sparse-checkout set –no-cone someFOLDER
$ git checkout
To convert a repo to shallow:
https://stackoverflow.com/questions/4698759/converting-git-repository-to-shallow
> git pull –depth 1
> git gc –prune=all
Convert to shallow since a specific date:
> git pull –shallow-since=YYYY-mm-dd
> git gc –prune=all
To cancel a git merge:
> git reset –merge && git merge –abort
To reset a file to be the same as the one in the master branch:
> git checkout master – some/path/file
To view one commit, details + file names, no patch:
> git show b7da2… –format=fuller –name-only
To view the diffs/changes of only 1 file:
> git log -p some/path/file
To filter changes of one file with pickaxe:
> git log -S’Foo’ –since=2019.1.1 –until=2020.1.1 – some/path/file
To filter changes of one file with -G search:
> git log -G’Foo’ –name-status – some/folder/
To change the author of ALL commits:
> git filter-branch -f –env-filter "
GITAUTHORNAME=‘New name’
GITAUTHOREMAIL=‘new@email’
GITCOMMITTERNAME=‘New name’
GITCOMMITTEREMAIL=‘new@email’
" HEAD
How to remove files from a commit:
https://stackoverflow.com/a/15321456/498361
> git reset –soft HEAD^
> git reset HEAD path/to/unwantedfile
> git commit …
How to undo a local commit (not pushed):
> git reset –soft HEAD~
Undo a commit local & remote:
> git reset –hard HEAD~
How to remove a commit:
https://itechcode.com/2020/09/22/how-to-remove-a-commit-in-git
> git rebase –interactive origin somebranch
How to restore a deleted tag:
https://baptiste-wicht.com/posts/2011/06/git-tip-restore-a-deleted-tag.html
> git fsck –unreachable | grep tag
> git show ID
> git update-ref refs/tags/TAGNAME ID
Cleaning up Git history:
https://blog.sulami.xyz/posts/cleaning-up-git-history
Conditional Git config:
https://utf9k.net/blog/conditional-gitconfig
Setup different authors per repo, setup multiple authors per commit:
https://advancedweb.hu/3-ways-to-set-up-author-information-in-git
Forking and maintaining a fork:
https://docs.github.com/en/get-started/quickstart/fork-a-repo
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork
# hard reset, completely replace fork master with upstream master
git fetch upstream
git reset --hard upstream/master