2024-01-04: Notes on Using Git

I keep a private folder of bare repositories "~/repos" with all git repositories cloned from there. Code meant for public use is then pushed additionally to codeberg or notabug by adding them as a second remote.


New Repository

> cd ~\repos
> mkdir new-project.git
> cd new-project.git
> git init --bare
> cd ~\projects
> git clone ~\repos\new-project.git
> cd new-project

TIP: to reveal the hidden git folder in CMD use attrib -h .git



> git remote -v
> git remote add nb https://notabug.org/PATH


Tags can be added with a message, but must be pushed separately from the code, by individual tag or all tags.

> git tag -a v1.4 -m "my version 1.4"
> git push origin v1.4
> git push origin --tags


A branch represents an independent collection of files within the project. This can be useful for keeping some code "local only", or for creating codeberg pages.

> git branch hidden
> git checkout hidden
> ...
> git push origin hidden
> git checkout trunk

Sometimes Useful

List all the committed files in the repository:

> git ls-tree --full-tree -r --name-only HEAD

.gitconfig / .gitignore

The global .gitignore file is used to hold extensions/file patterns which should not be committed.

Page from Peter's Scrapbook, output from a VimWiki on 2024-01-29.