If we check wikipedia, here is what it says about Git:
Git is a version control system (VCS) for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files.
There is no doubt Git has an important role on the web development world. From controlling versions of your software, to colaborate with people online. There is one thing with Git though, it can be "scary" to start with it. New commands, work from the console... but fear not, here you have all the basics you need to know to start.
First of all, assuming you have git installed, you need to start your git project. On the root file:
$ git init
At some point, you'll probably want to know which files are not yet added to git, which ones have changes... You can do this by typing:
$ git status
You'll see the results on the console with a nice explanation.
If you have files to add, you'll see them on the list. For example, if you created a new file called "helloWorld.md", you'll see it on the list. To add this file, you can do:
$ git add helloWorld.md
$ git add .
To add everything on the list.
$ git add '*.md'
To add everything with the extension .md on the list.
This will put the file(s) on the staging area. Waiting to commit. To commit the changes, you need to type:
$ git commint -m "Some helping message here"
It's very important to add comments to our commits and make them as helpful as possible. You don't need to fit your commit message into one line. You can include a text file.
Now that we have commited our changes, we can see the log.
$ git log
Here you can see all the commit history.
Sometimes, we have files on our projects that we don't want in our git repository. To accomplish this, we just need to create a
.gitignore file and add our rules.
For example, if we don't want to add all the nmp dependencies and exclude all the .txt files, we can create a .gitignore file with the following:
Gitignore files can get complex. GitIgnore.io is a great tool to generate them.
Looking for some practice? Github makes it easy for you. Try it out!