Walking Through Git:

Piyush Kumar
5 min readJun 28, 2022

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

Downloading Git

  • First of visit to official git web-site and download the latest version of git for your windows/macOS as per your compatibility.
  • After downloading the git version, leave the default setting and install it.
  • After installing, open any terminal of your choice e.g., git-bash, vs code terminal, windows terminal, etc.

Setting up Git

  • Now run the command on the terminal “git — version” and it shows you the git version that you have downloaded.
  • This shows that git is properly installed in your device by now.
  • Now, if you are downloading git for the very first time then, we have to set some configs for this.
  • Now set your email as “git config — global user.email “your email” by running this code in your terminal.
  • Here by the time, your name and email has been set.
  • In-order to make an directory we have to run the command,
  • And by using cd command we can reach out to the folder.
  • Now in-order to make that ongoing folder as a git repository, we have to run the command “git init”.
  • After setting up, in-order to see what we did modification, or any changes we can run the command “git status”. By running this command we can see each changes drawn in the folder and everything that takes place.
  • The process of git,
  • “Working directory” is done as we create a directory and then by adding any file we reach out to the “staging area”. Now for the last part i.e., git commit by running the command “git commit -m “initial commit”.
  • By doing this, the file which is present in your directory gets commit by git and now in-order to check how much commit you have already committed previously by any contributors for the file or by you, then we have to run the command “git log”. This command shows you the hash-code of all the commits by the author.
  • Now by creating more files in your directory and wave through the following commands above. And you can see the changes going on.
  • Now inspite of using “git add filename”, we can use “git add .” by doing so all the files present in your directory reach the “staging area”.
  • By by running the command “git log” we can see all the commits that has been don, and we receive different commit. Now if we have to focus on a single commit we can run the checkout command by copying the hash code of that commit and paste it in the following command.
  • Now in-order to go back to the original position we have to run the command “git checkout master”.
  • Now to check the branch we have to run the command “git branch”.
  • By default master is the main branch, so we can create tree from the main master branch, in-order the create another branch we can run the command “git branch name”. Then we checkout that branch.
  • So its a kind of long process, so in-order do this work of creating the branch and checkout command on the same line we have to run the command “git checkout -b branchName”.
  • If we did any changes with that new branch the we can run the command to merge that changes in the new branch is “git merge branchName”.
  • After finishing your project, you don’t want to make the sensitive information like key to be public, so in-order to make in private and protected we can save that sensitive info in the “.gitignore file”. This can be done by the command “touch .gitignore”.

Github Intro

  • After creating a repository we can run the following command as shown by the github itself,
  • Now if we do any changes to our file than to make it appear in your github we have to run the command “git push”.
  • Now if we want to push our all branches that we created rather than master one than we will run the command “git push -u origin branchName”.
  • For open source contribution, fork a github repo and clone it in your IDE by running the command “git clone <repo url>”.
  • Now you can make changes to the repo as it gets clonned in your device.
  • So that’s all for this.

Thank You

--

--