Git is a version control system for everything from small sites to large scale apps and sites. The first step is to download and install it on your machine whether your OS of choice is (Windows, macOS, Linux). Although there are GUIs available e.g. Github Desktop it is easy to get started on the CLI (Command Line Interface) which could be the terminal like or git bash or the built-in terminal in your editor.
You can get started by creating an empty repository (or repo) on your host of choice mine is Github you then clone that empty repo into your files which creates a copy of this locally and then add your files to this folder. If you already have a folder with files you wish to add to git you can do this with the following commands (which will be shown to you):
git remote add origin firstname.lastname@example.org:'YOUR_USERNAME'/'REPO_NAME'.git git push -u origin master
git add: this command add files to git and makes sure any changes are 'tracked' which are added to the 'staging area' - this is the middle man where you can check any updates/changes before committing
git commit: this commits or finalised your changes when using this you need to add
-mwhich is a relevant message explaining your changes e.g.
git commit -m 'updated footer'
git push: this 'pushes' any changes to the remote repo on Github so it is accessible to everyone -
git pull: this opposite to push this will 'pull' any updates into your local repo so you have the most recent changes available to you
git status: this will give you information about your files e.g. whether or not changes have been made and whether they have been tracked
git rm: remove a file from the 'staging area' if updated by accident -
git log: this will give a list of the most recent commits e.g. date and who committed the updates
git diff: this will show differences between original files and the most recent updates
git branch: this is most useful for larger software/app projects where you can complete updates without modifying the original content e.g.
git branch footerfix // creates a new branch called footerfix git branch - master - footerfix
The default branch will be the
master, but you can create several updates for different things you may be working on. Switching branches use the
git checkout BRANCH_NAME e.g.
git branch * master // this will be the default branch footerfix // switches from the master to the new footerfix branch
To delete a branch, use the
git branch -d footerfix