Use git to control the versions of your code. Git grabs each modification you make in your code.
In all Linux distros, git is already installed, or if not you can install it.
# Debian based
sudo apt install git
# Gentoo based
sudo emerge -av dev-vcs/gitEdit Configuration file
vim ~/.gitconfigCheck global configuration
username = USERNAME
email = EMAIL@MAIL.ORGOpen new folder and initialize git with the command
$ mkdir newFolder
$ cd newFolder
$ git init
$ touch emptyfile
$ git add emptyfile
$ git commit -m "adding my first empty file"Using git
$ git diff
$ git add file
$ git commit -m "file modification messagem"
$ git pull # ensure all files from repo are synchronized
$ git push # update / upload files to repositoryDon’t forget to configure / create access token in github pages / gitlab, etc…
Install github-cli: useful to create repositories, etc.. without login in into website.
# install golang before continue
# debian based distro
$ sudo apt install github-cli
# Gentoo based distro
$ sudo emerge -av github-cliLogin with github-cli ( gh )
$ gh auth loginIt is recommended you save your github token into some environment variable
$ export GH_TOKEN="alisdjasdjçasidjaçsjdaçsokdaçsd"Monkey prefer to save githuToken in file and encrypt it.
$ gpg --encrypt --sign --armor -r monkey@banana.world githubToken_file.txtThen, in .gitconfig add the line:
If user have private servers to use they can setup ssh-server and become a git-server.
$ mkdir repository.git # Termination with .git is necessary
$ cd repository.git
$ git init --bareThen from developer machine you want to clone that repository.
Lets imagine your git-server machine IP is 192.168.100.100 with a user git.
$ git clone git@192.168.100.100:/home/git/repository.gitInstall tig to see git history
$ sudo emerge -av tigConfig git alias to work faster with git.
$ git config --global alias <alias> <command>Useful alias:
[alias]
co = checkout
cm = commit -m
rl = reflog
pu = pushLike in Linux, we can set the name we want to the [aliasname]
Find lost files :
$ git fsck --lost-foundClone missing submodules
$ git submodule update --init --recursiveCheck Naughty Monkey Thoughts