GIT BASICS FOR BEGINNERS.
In these tutorial, I am going to explain some basic git commands that any beginner should know in order to track their project.
What is Git?
Git is version control system that helps you track changes in your project. It helps you know exactly what you changed and when you did it.
Why use Git ?
As a Beginner, there are two reasons why you need to use git:
- Collaboration- you can work on a project with a friend or a team.
- Reverting a project- sometimes you screw up things and you might need to go back to where you started. Git is perfect tool for you.
Git Basic Commands
- git init - This is a command to initialize the repository. it simply tells git "please start tracking my project from now".
> git init
Initialized empty Git repository in /home/kiprono/Desktop/New/.git/
- git status - As the name suggest, this command is used to check the status of the repository. By this I mean whether the files have been tracked , which ones are staged and which ones have not been tracked.
> git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
dist/
nothing added to commit but untracked files present (use "git add" to track)
- git add- when you make any change like creating a file, you often want to make git aware of those changes.
git add .
command helps you do exactly that.
- git commit - once you have staged your changes with
git add command
, the next step is to tell git to persist the changes.git commit -m "description"
is the command to do exactly that. Notice it takes-m
flag and description as string. Description is just telling git what changes you made and perhaps why you did it.
> git commit -m "first commit"
[master (root-commit) 91674a2] first commit
1 file changed, 1378 insertions(+)
create mode 100644 dist/homepage.tw.html
git remote add origin- It is not always safe to keep you code locally on your computer. Something bad might happen and you project will be gone forever. To always have your project tracked remotely, you will need a github account. This will help you push all of your local code to remote repository. To do this, you will need to add url to your repository in local folder like so
git remote add origin https://github.com/KIPRONODENIS/Tailwind-Template.git
. In the above example, I have used my url but that will be different in your case.git push -u origin master - The final step is to push your code into remote repository. This is done with the command
git push
orgit push -u origin master
CONCLUSION
That is all you need to get started at the very least guys. If you want to deep dive more with me , you may let me know in the comments section below. You can as well reach out to me here .Thanks for stopping by and I will see you in the very next one.