Tumgik
farhanbudye · 3 years
Text
Starting with git
Hello everyone! hope you're doing great, and you are learning new things whether it may be in the aspect of your professional and/or personal life.
This is my first blog ever!Anyways...
I am Farhan Shakil Budye - Web developer My interests are learning new stuff everyday (even small things), going on trek, crazy bike lover, big football fan btw...
I am starting a series on getting started with git. I am no expert so kindly feel free to correct me if I’m wrong somewhere. From that I will be able to learn, research and rectify.
Excited to be here!
Enough with the boring stuff now starting off with our main topic "Starting with git”.
What is git?
git is a version controlling tool it is command line tool used for -
i) keeping track of changes while working on code, making copy of the file, syncing the codes altogether etc...
ii) helps take snapshot (not a screenshot) of the code.
There are a lot of other uses for git which you can look online too. As I won’t be going in deep with the use cases assuming all of you might be having some information or might have heard within a group about git as it trending a lot.
Downloading/Setting up git on your local file - Link https://git-scm.com/downloads > Choose your OS > Double click on the setup file > Follow all the necessary steps by clicking "Next".
Voila! After you are done with the 1st step then just for getting it confirmed whether that git has been successfully installed on your machine/laptop. For that you have to just open your command prompt / cmd type git --version if you've followed all the steps correctly then you should be displayed with a message something like this "git version 2.32.0. windows.2". If you have received this message with the version and stuff that means git is successfully installed on your machine/laptop. If not, you will have to repeat step 1 again. P.S. skip the downloading part of course.
Since git is a command line tool you should be aware of few if not each command.
Here is a list of command that I’m going to cover in this blog.
git clone <URL> (URL to be cloned/copied on your local machine/laptop)
git add filename
git commit -m "Message"
git status
git push
git commit -am "Message”
git pull
git log
1. git clone <directory-URL> (directory to be cloned/copied on your local machine/laptop)
This is the very first command that if you want to clone/save a copy of your directory on your machine/laptop.
2. git add <filename> -
i) This command is very important if you want to commit and push any changes that you've made into your file.
ii) This command allows git to understand that this is the file you want to keep track of and monitor this one.
3. git commit -m "Message" -
This git command allows you to commit/save the file with -m "Message" indicating any note you want to mention for you or the other developers to be identified easily.
4. git status
This git command returns with the status of your branch master.
5. git push
This command is very important for pushing/uploading the changes made into your local file to be uploaded on to the git repository.
6. git commit -am "Message”
This git command is used to add a common message to all of your file at a same time just unlike git commit -m "Message" which allows to only add comment to a single file.
7. git pull
This git command allows you to pull and automatically merge the difference between two files. Usually it will merge most of the things but there are certain exceptions for which it won’t automatically merge your local repositories file. For that you will be getting an error or message in your command line tool that there has been a merge conflict in this file.
Note: For situations like the changes that haven't been updated in your local file will be separated by "=========" and you can filter which change you want to keep and merge and which to eliminate.
8. git log
This git command will give you a track record or history with all the commit messages, when it was pushed, by whom it was pushed etc.
Below are some additional useful commands that might be good to know about
echo <filename> (creating a file using command line for Windows users)
touch <filename> (creating a file using command line for Linux, Mac users)
code <filename> (Opening a file in the text editor)
cls (clearing the terminal screen for Windows users)
clear (clearing the terminal screen for Linux, Mac users)
dir (listing/displaying all the files in current directory/folder for Windows users)
ls (listing/displaying all the files in current directory/folder for Linux, Mac users)
cd (clearing the terminal screen for Windows, Linux, Mac users)
Hope you have enjoyed my first blog.
Let me know what you all think of it in the comments below.
Glad to hear feedback or inputs from all.
Happy coding!!
2 notes · View notes