The following guide covers the basics of Git: installing Git on your system, initializing repository, commiting files, adding remote, and collaborating on branches with other users. This is some pretty straightforward stuff, good to keep at hand until Git becomes your lifelong friend for good and bad.
A NOTE BEFORE YOU GET STARTED The best way to understand how Git works is to run Git commands from your terminal. If you’re a Windows user make sure to run git bash when adding your Git package.
First you need to choose and install the package for your OS:
Once the Git is installed, go to the folder with your project and run
to initialize Git in this directory. This command will add a
/.git directory to your folder that will store data about the repo.
Adding files to the repository
Now we need to tell Git to put the files under version control so we can commit them. To do this, run:
git add .
With ‘git add’ you can define which files you want to add to the next commit:
git add filenamewill add a specific file
git add .will add all files from the directory.
Once the files have been added, you can commit them to the repository:
git commit -m ‘Added all files to the repository’
-m stands for the commit message. Always write something that describes your activity in the commit to avoid mess when browsing the history later on.
To view which files have been added and/or modified, use…
Want to learn more? Check out the full article here.
Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.
If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!