Incomplete |
Install git
Install git from the official website: https://git-scm.com
Authenticating git
We need to set up our Github username and password. Once git is installed, set it up using these commands on Terminal:
git config --global user.name <Github username>
git config --global user.email <Github email>When prompted, type in your password and hit enter.
To check which user credentials are currently logged in:
git config user.name
git config user.email Basic command line
- Creating a directory:
mkdir <folder_name> - Creating a file:
touch <filename.txt> - Deleting a file:
rm <filename.txt> - Deleting an empty directory:
rmdir <folder_name> - Delete a directory with all files inside it:
rm -rf <folder_name>
Initialise git
Change directory into your project folder and initialise git as follows:
git initQuick diagram of how git works

Staging
To see which files are in the staging area:
git statusTo add a specific file to the staging area:
git add <filename.txt>Adding files
To add files to the staging area, there are a few different commands depending on what you want to do.
To stage all changes (including new files, modifications and deletions):
git add -ATo stage only new files and modifications (not deletions):
git add .To stage only modifications and deletions (not new files):
git add -uBy the way:
git add -Ais the same asgit add --allgit add -uis the same asgit add --update
The . means the current directory:
Commit
To commit the files in your staging area:
git commit