Git and Github Usage Guide
Git as a Version Control System
Greetings to everyone, in this article, I will talk about Git software, one of the version control systems, which is a very important issue in the lives of all our Software Developer colleagues, regardless of department, and Github, which is a remote environment.

Content of the article :
- What is Git and Github?
- Git installation
- Git Usage
- Basic Git Commands
- Github Guide
- Best Practices Git Commands
What is Git and Github ?
Git is a version control system. At this point, if you ask what is a version control system; each feature, hotfix and similar developments in a project are a version. for example, when you add the ability to register with a social media to your project today, if you commit this code and this commit becomes a version of your project. then at any point you want, you can go back to the version before the version you want, or you can only provide a fix for that version.
At this point, the software to create and manage these versions is called Git. You can find more detailed information on Git Usage and Basic Git commands.
Also Github is a remote repository that allows you to send these local versions to a remote repository and work as a team.
Git installation
For Git Software you can go to the official site from the link HERE

As shown in the image, you can select the operating system suitable for your computer and start the download process.
Also It will open an area on the side for you to download the appropriate OS and latest version with the information taken from your browser.
Git Usage
At this point, we will set up how Git software will exist in your project. I will show an example from my usual example project, Spring Core Template.
To Terminal (if you use windows which it is name called console)
git init
Within the project files, it creates a file called .git (default hidden file) which contains the git config information.
Now every development you do will be detected by the IDE and colored as Blue Green and Red.
Red : non versioned files
Blue : Edited file
Green : Newly created file

Now that we have Git installed and working with our project, we can see the basic commands.
Basic Git Commands
git status
With this command we can see our files that are not yet versioned, as you can see below.

I need to define the files here to my version. For this we need to recognize the git add command.
git add <File>
in this use I will only include that file in the version. however you type to console git add . select all files
now let’s look at the situation by doing git status again.

now the files are ready for commit.
git commit -m “fixed sms service issues”
in this example I fixed a problem in the sms service and created a version of it.

Please note that so far this has only created a version on my local computer. If you are working as a team or need to move the code to Github for some reason, you need to Push Existing Commits
Github Guide
First of all, you should have a repository where you can store your existing project and versions. The most commonly used platforms are Github and BitBucket. I prefer Github.
You need to create an account for yourself at github.com Remember that this account will be with you as a software developer throughout your software life.

Uploading your project to Github
we have 4 different option for that
- Create Repository from website
- Create Repository via IDE
- Create Repository via Github Desktop
I will only explain how to do the first 2 steps as I consider the Github Desktop tool to be redundant.
Create Repository from website Steps :
Click on the Repositories tab, press the New button on the side and fill in the necessary information on the screen that opens.

You need to pay attention to Privacy Settings. If you are developing a commercial application or if it contains code that you do not want other developers to see, it would be better to choose Private.
You can add contributors to the Private Repository at any time
Existing project and Remote Repository Association
Now let’s associate our code in our IDE and our repo on Github. for this
git init
git add .
git commit -m “initial commit”
git remote add origin <remote repo git address> (https://github.com/UlasMuezzinoglu/testRepositoryForMedium.git)
git push -u origin master
When we run these codes in our terminal, our project and our remote repository will be connected. from this point on, we can commit the codes we have written and then do the push operation.
You can create a Repo via IDE.
I will use the Intellij IDEA IDE for this process. First of all, while my project is open, I click on the VCS Tab above and select Share Project On Github.
The screen that opens will be exactly this.

First of all, it will ask you for verification. For this, it will open another modal and redirect you to the browser. After you confirm on the screen that opens, you can return to the idea. This modal will welcome you.
In the first step, you will only need to select Repository Name and Privacy setting. Then, with the Share button, you will both create a repository on Github and associate your project. It will also create the .git folder that appears when you create it from the terminal.
Some Config Files
.gitignore : any file you write in this file will not be detected by Git. You can prevent files you don’t want, such as .yml or .properties files, Log Files and similar files from being dropped to Github by specifying them here.
README.md : as the name suggests, it is the file where you introduce your project. It has a Markdown extension, you can find many resources about its use on the internet.
Best Practice Git Commands
This is perhaps the most interesting section. Here I will list git commands and usages that will be very useful when used from the terminal.
git clone : is used to clone code from a remote repository to our local machine.
git clone <repo url>
git branch : lists all branches on the current repository.
git branch
git checkout : with this command we can navigate between branches. If you use the -b option, it creates a new branch and switches to it.
git checkout <branchName> || git checkout -b <BranchName>
git merge : merges the history of the branch we want with the current branch.
git merge <BranchName>
git diff : This command shows file differences that are not yet progressive.
git diff
git config : sets the user name and e-mail address to be used with the values you give respectively.
git config –global user.name <name>
git config –global user.email <email>
git init : as mentioned above, it is used to initalize the repository.
git init
git log : This command lists all version/commit history of the current branch.
git log
git reset : every development sometimes doesn’t go the way we want and errors may occur. this command allows us to return to older versions. It has 2 uses.
git reset <commit no> || git reset --hard origin/<BranchName>
git rm : deletes the file from the path.
git rm <file>
git pull : This command brings changes from the remote server to the current branch and merges them.
git pull origin <BranchName>
I tried to explain Git Software and the Github environment as much as I could. Of course, such a big concept is not something that can be covered in a single article. But even this much use means more than maximum skill.
You can visit my Github Address and Linkedin Profile to support me.
Thanks in advance, Good works.