Git Tutorial for Beginners: Commands and Workflow
Git saves every change you make to your files, so you can undo mistakes and work on the same code with your team. Start here with the setup and the commands you will use every day.

Contents


What Is Git, What Is It Used For, and How to Use Git
To a question like “What is Git, what is it used for, and how do you use Git?” we can give the shortest answer: Git is a version control system. The need for these kinds of services is actually designed for when you work as a team and to help developers make the development process more controlled. Many software developers these days use GitHub and GitLab. So how is Git used, and what are the basic commands? Now let’s examine these starting from the very basics.
Version control system (VCS) or (SCM – Source Control Management)
It is a tool used to track and manage changes to the source code, documents, and other files created for a software project. These systems store different versions of each file or group of files and track the changes between these versions.
VCS tools also make it easier for multiple people to work on and make changes to a project at the same time. Each person gets the latest version of the project and makes changes. The VCS system makes it easy to merge changes and resolve conflicts.
VCS also offers the ability to easily go back to older versions. If a bug is found in a project or if it turns out that a previous version was better, the VCS system lets you easily revert to an older version.
The most common VCS systems, such as Git, Subversion, and Mercurial, offer all these features and more and provide great help in the software development process.
Using Git
Using Git is quite simple. First, create a folder where you want to copy the project’s source code. Then get the link to the project’s Git repository and download it into the folder using the “git clone” command. This will download the entire project to your local computer.
Installing Git
Go to http://git-scm.com/downloads, download the version suitable for your operating system, and perform the standard installation on your computer. Also, if you are using a Linux-based operating system, you can install it with the command below.
sudo apt-get install git
After the installation is complete on your computer, go to the Windows Start menu, find the Git folder, launch “Git Bash“, and start using the Git command line interface. If you have access to the Git command line, you can run the command below to find out which version of Git you are using.
git --version
Basic Git Configuration and Getting Started
If you’ve successfully completed the Git installation, we now need to make a few small settings to start using Git. These settings are required to indicate who made the updates and changes, and you can change them at any time. To configure Git settings, use the following command.
git config
The settings you make for Git are written to specific locations on disk depending on certain conditions.
1. Git System : If Git settings are written to the /etc/gitconfig file, they apply to “all users and projects”. If you want to apply a setting this way:
git config --system
2. Git Global : If Git settings are run with the following command, they apply to “your user account”.
git config --global
3. Git Local : If your project is under Git version control, there will be a file named ./git/config. To use Git at the local level, you can use the following command.
git config --local
Now that you understand the Git levels above, we can move on to defining a Git user. You can set the email address for your Git account as shown below.
git config --global user.email "serhat@serhatalpaslan.com"
You can also use the following commands to view the settings used for the Git service.
Global ayarları görmek için ;
git config --global -l
Sistem genelindeki ayarları görmek için
git config --system -l
Proje genelindeki ayarları görmek için
git config --local -l
Also, to understand what Git is and start using Git commands, you’ll need to learn all of it very well. In addition, I recommend creating an account on GitHub and practicing a lot. To create a GitHub account, you can use this link. Also, check out our lessons related to What Are Git Commit, Revert, and Diff and How Are They Used?.
Git Commands
Git commands let you manage your project using Git. These include essential commands such as “git add“, “git commit“, “git pull“, “git fetch“, “git checkout” and “git branch“.
Using Git Clone
Git clone is the command used to copy a project from a Git repository. The git clone command copies all of the source code to a local folder.
What Is Git Pull?
Git pull is a command used to download the latest updates from a Git repository. The git pull command updates your local project with the latest version in the Git repository.
What Is Git Fetch?
Git fetch is a command used to download the latest state of the project from a Git repository. The git fetch command syncs your local project with the latest version in the Git repository, but it does not modify your local files.
What Is Git Checkout?
Git checkout is a command used to get a specific version from a Git repository. The git checkout command lets you switch to a specific version and run your project at that version.
What Is Git Commit?
Git commit is a command used to save changes made to your project. The git commit command saves your files to the local repository and adds them to the repository with a message.
What Is Git Add?
Git add is a command used to add new files to a Git repository or save changes to existing files. The git add command adds new files or changes to the local repository.
What Is Git Branch?
Git branch is a command that lets you manage different development paths in your project. The git branch command lets you create a new branch in your current project or switch to an existing branch.
What Is GitHub?
GitHub is a web-based service that hosts Git repositories and lets you share projects.
Share it if it helped

