Hey Devs,
Today we are going to talk about git. Now the biggest question is.....
What the hack is git?
If you are the one who already heard about git or version control system and don't know what actually is it. Let's dive into it and understand it.
Git can be defined as a version control system that stores, manages your code. if you are developing a software, you will add features in that software one by one. Now let's say the feature you have added yesterday is not working properly and you just want to remove that feature and want to clean the code but you ended up with a mess. This really sucks, isn't it.
But to save you from this pain git comes in role. you can rollback to the last stage where you were, all you need to commit your code.
Here's a quick guide to install git and make it work in your machine.
For installation goto to official website of Git and download it for your operating system and follow the on screen instruction.
Once you done with installation open terminal and type
git --version
this command will show the current version of git, it means you have successfully installed git.
To configure username type
git config --global user.name "Your Name"
in the terminal and hit enter.
To configure email again type
git config --global user.email name@example.com
If you finished the above process successfully, congrats git is ready to work for you.
Now whenever you create new project just open the terminal and navigate to the project's directory and just type this command.
git init
This command initialise git in your projects directory and git will keep track of each and every work that you write in your code.
But initialising git isn't help you so you need to commit you code. Committing code means git will store your code in local repository not on remote server.
Enter this command to commit your code.
git commit -m "Some message"
Hah, we have done a lot of work but wait git comes with lots of features we haven't even heard. The other most important feature is to push you code to remote repository so that you can access it on any machine at any place.
That's sounds awesome, isn't it?
So to push your code to remote repository you need to connect git to Github or Gitlab or any other remote repository. Just go to their official website and follow the instruction to connect your git.
Once you done that, just type this command in terminal.
git push origin master
Replace origin with the branch name if you want to push to another branch.
Git is full of features and we have covered only basics of it because i think these features are enough to get started with git. I will talk about more features in the future posts till then Good bye and happy coding.
Note:- May some commands will not work with windows because they are Mac specific so please find the alternate for that.
Top comments (0)