Before jumping into the code, let's first try to cover some common terminologies related to version control.
allows you to revert files back to a previous state, revert the entire project back to a previous state, review changes made over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.
directory that contains your project work which are used to communicate with Git. Repositories can exist either locally on your computer or as a remote copy on another computer.
Git thinks of its data like a set of snapshots of a mini file system. Think of it as a save point during a video game.
A SHA is basically an ID number for each commit. Ex. E2adf8ae3e2e4ed40add75cc44cf9d0a869afeb6
The files that you see in your computer's file system. When you open your project files up on a code editor, you're working with files in the Working Directory.
When content in the repository has been copied to the Working Directory. It is possible to checkout many things from a repository; a file, a commit, a branch, etc.
You can think of the staging area as a prep table where Git will take the next commit. Files on the Staging Index are poised to be added to the repository.
it is when a new line of development is created that diverges from the main line of development. This alternative line of development can continue without altering the main line.
Git has three sections/areas
Next, if you haven't installed git on your computer :
For windows users, install git bash from the following link : Download Git
git config --global user.name "<your name>"
git config --global user.email "<your email>"
Go to your github account and click the button New, which is a button for creating a new repository. Then give it a name and click on the create repository button.
git clone <url> [local dir name]
This will create a directory named , containing a working copy of the files from the repo, and a .git directory
Now you can start adding and commiting changes to your repository.
touch test.py
git status
Go ahead and try the command now. It will tell you that there is an untracked file and asks you to add the file using the add command.
git add <filename> in your case,
git add test.py
To add all new files you have created to the staging area, use the following command
git add .
git commit -m "<message>" in your case,
git commit -m "added test.py"
The message part is to describe what kind of change you have made to your directory or code.
Now check the status of your working directory using the status command.
You should be seeing "nothing to commit, working directory clean" message.
While working on your project there might be files which contain credentials and some other sensitive informations that you don't want to share to everyone.
For example, lets create a simple txt file with a name password.
touch password.txt
Lets assume this password.txt file contains a secret information and you don't want Git to track it.
To make git NOT track specific files, create a .gitignore file and add the file name in it using ur prefered text editor.
touch .gitignore
Now open the file in any editor and write password.txt on the first line of the file. Then use the add and commit command to save the changes you made.
Note that when you use add, it didn't track the password.txt file.
If you wish to make git not track all of txt files, you can add '*.txt' (without the quote) on the .gitignore file.