Git is a version control system that I’ve found useful to keep track of changes made to everyday scripts. Install it in ubuntu with:
sudo apt-get install git
Setup with username and email:
git config --global user.name "Your Name" git config --global user.email "email@example.com"
Check these details later if you want with:
git config --list
create our workspace environment:
mkdir -p ~/git/testing cd ~/git/testing
create a test file to use in our repository:
tell git that you want to use your current directory as a git environment.
add all files and directories to your newly created repository (no output is good output):
git add .
create the message for our initial commit (continue doing this every time you make changes to a file, with an appropriate message):
git commit -m "Initial Commit" -a ## for all files git commit -m "Initial Commit" file ## for specific file
Check for previous versions:
use the commit number/code in this command if you want to revert to a given version (assuming here that the commit version is abcde):
git checkout abcde file
Usage with github
If you have a github account, pull a repository from there with:
git clone https://github.com/yourname/yourrepo.git
You can commit to you local repository as usual:
git commit -m "change to files" -a ## for all files
if you are happy with the changes, you can push to your github repository with:
git push origin master