Notes on the version control system


git init

Initializes a repository in the current directory

git status

Shows changes files

git add filename

Stages a file

git commit -m "Insert Message"

Commits the files

git push/pull

Pushes or pulls the latest changes

Pushing a new repository to Source Hut

git remote add origin

Creates the remote repository

git push -u origin main

Pushes the default branch to the remote


Installing the latest version of git on an LTS Ubuntu distro:

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

Renaming the main branch

git branch -m master main

Renames the local branch

git push -u origin main

Pushes the new main branch to the remote

gut push origin --delete master

As of Git 2.28 it is possible to configure the name of the default branch:

git config --global init.defaultBranch main