top of page

What is Git and How to Use It?

Updated: Mar 8



Git is a version control system for software development. It allows developers to track changes in their code, collaborate with others, and roll back to previous versions if needed.

To use Git, you first need to install it on your computer. Once installed, you can initialize a new Git repository in a directory by running the command "git init". You can then add files to the repository using "git add" and commit changes using "git commit" with a message describing the changes.

To collaborate with others, you can push your changes to a remote repository (such as on GitHub) using "git push" and pull changes made by others using "git pull".

Git also has a number of other useful commands such as "git status" to check the current status of the repository, "git diff" to see the differences between commits, and "git log" to view the commit history.


How to Install Git?


Windows:

  1. Go to the official Git website (https://git-scm.com/download/win) and download the latest version of Git for Windows.

  2. Once the download is complete, run the installer by double-clicking on the downloaded file.

  3. You will be presented with the "Welcome to the Git Setup Wizard" screen. Click "Next" to continue.

  4. On the next screen, you will be asked to choose the destination folder where Git will be installed. You can choose the default location or select a different folder. Click "Next" to continue.

  5. On the next screen, you will be asked to choose the components that you want to install. You can choose the default options or select custom options. Click "Next" to continue.

  6. On the next screen, you will be asked to choose the start menu folder where Git's shortcuts will be placed. You can choose the default folder or select a different folder. Click "Next" to continue.

  7. On the next screen, you will be asked to configure the line ending conversions. You can choose the default option or select a different option. Click "Next" to continue.

  8. On the next screen, you will be asked to configure the terminal emulator that Git will use. You can choose the default option or select a different option. Click "Next" to continue.

  9. On the next screen, you will be asked to configure extra options. You can choose the default options or select custom options. Click "Next" to continue.

  10. On the next screen, you will be presented with a summary of the choices you have made. Review the choices and click "Install" to begin the installation process.

  11. Once the installation is complete, you will be presented with the "Completing the Git Setup Wizard" screen. Click "Finish" to close the wizard.

  12. Now you can open a command prompt and run the command "git --version" to verify that Git is correctly installed.

macOS:

  1. Open the Terminal application on your Mac.

  2. Run the command "brew install git" to install Git using the Homebrew package manager.

  3. Wait for the installation to complete. You will see the progress and outcome of the command on the terminal.

  4. Run the command "git --version" to verify that Git is correctly installed.

Linux:

  1. Open a terminal window.

  2. Run the appropriate command for your distribution's package manager to install Git, such as "sudo apt-get install git" for Ubuntu, "sudo yum install git" for Fedora, or "sudo pacman -S git" for Arch Linux.

  3. Wait for the installation to complete. You will see the progress and outcome of the command on the terminal

  4. Run the command "git --version" to verify that Git is correctly installed.

Please note that depending on your specific operating system version and the package manager you may have to adapt the commands accordingly.

Additionally, you may also want to configure your Git settings after installation. This can include setting your username and email address, which will be associated with your Git commits, as well as configuring any other settings that you want to change from their default values. You can do this by running the appropriate Git commands in the terminal.


Is The Above Explanation Not Enough For You?

'!!! Follow Step by Step Git Installation Below !!!




Let's install Git together according to the Windows operating system.


First, we download Git to our computer from git-scm.com/downloads.




We run the Git setup file we downloaded. After saying "Next" in the first window that opens, it shows us where to install it classically, you can stay that way or you can change it. After you pass this step, the "Select Components" section comes up and you can still keep it as default and continue by saying Next.





After this step, it can directly give the "Select Start Menu Folder" step. We have to run the unit that uses the later settings by default. As an example, let's select the default Visual Studio Code, Use Visual Studio Code as Git's default editor option. (You may not choose Visual Studio Code, choose whatever text editor you are using)



We chose the text editor we want to use by default, and then a screen like the one below will open, and we determine how we will use Git on that screen. You can choose the suggested option "Git from the command line and also from 3rd-party software". This option allows us to use the "Git Bash" program as well as the Git commands with the "CMD" (command prompt) window. To do this, the Git directory must be added to the environment variables.




Now we will select the "Use the OpenSSL Library" option, which is the method we will connect to.





Now we will choose the line break style. It is very important for us to choose as the style may change according to the operating system. The default "Checkout Windows-style, commit Unix-style line endings" option is available for Windows10 operating system.




Now we will specify the terminal that Git Bash will use. If you want, you can use the MinTTY terminal or use the classic "Command client". This is entirely your choice.





It can remain as default.





There are extra settings for using Git here. It can remain as the default settings without any changes. Click Next and complete the installation.



Congratulations, you have completed the Git installation.



What Are Basic Git Commands?


  1. git init: Initializes a new Git repository in the current directory.

  2. git clone <repository>: Clones an existing repository from a remote source. This command is used to make a copy of a remote repository to your local machine.

  3. git status: Shows the current status of the repository, including the files that are modified, added, or deleted but not yet committed.

  4. git add <file>: Adds a file or a group of files to the staging area. This command is used to prepare files for a commit.

  5. git commit -m "message": Creates a new commit with the changes that were added to the staging area. The -m option is used to add a commit message.

  6. git log: Shows the commit history of the repository.

  7. git diff: Shows the difference between the working directory and the last committed version of the repository.

  8. git branch: Shows the list of branches in the repository.

  9. git checkout <branch>: Switches to the specified branch.

  10. git merge <branch>: Merges the specified branch into the current branch.

  11. git push: Pushes the commits to a remote repository.

  12. git pull: Fetches and merges the changes from a remote repository.


43 views0 comments

Recent Posts

See All
bottom of page