Git is an essential tool in the modern developer's toolkit. Not only is it invaluable in keeping track of personal projects, it has also become a requirement for collaboration with other programmers.
Many linux distros will have git pre-installed. Use 'git' in your terminal to make sure it is installed on your system. If not, it should be in the defualt repos of the major package managers.
If you are on Windows, you will want to head to the downloads page of the git website. Download and click through the installation wizard. Now you should be able to find a program called "Git Bash" on your computer, open it and you are in business!
Enter the following commands to configure the name and email that will be associated with your commits:
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
Open your terminal (or Git Bash if you are on Windows) and navigate to the folder you want to make into a repository. For example, if my path is /home/cory/MyProject
the respository would include every file inside the MyProject
folder. Now go ahead and initialize the repo with the following command:
$ git init
Now that you have a respository initialized in your current directory, it is time to commit the files that are already there! Enter the following commands to add all the files in the directory to your repo and commit:
$ git add .
$ git commit -m "First commit!"
That is all! You have now successfully installed and configured git, and initilialized a repo!
From now on, whenever you make changes to the files/code in the directory of your repo, just add the files again and commit with an appropriate message that is concise and states what has been changed in this commit.
$ git add .
$ git commit -m "Add new section on committing to git-tutorial.txt"