How to Use GitHub? Git Push, Git Pull and Git Ignore Commands
How to run Standard Git commands on GitHub? How to run git commands on the local computer and submit projects to GitHub or pull projects from GitHub.

Index
- How to Make a Git Connection?
- How to Subscribe to GitHub?
- GitHub Developer Settings
- GitHub Tokens
- Personal Access Tokens
- Generate New GitHub Token
- GitHub New Project Creation
- GitHub ve Git Arasında Bağlantı Kurma
- Git Push Commands
- Pulling a Project from GitHub with Git Clone Command
- Git Pull (fetch)
- Git Ignore
How to Make a Git Connection?
To use GitHub, you must first have knowledge about git commands. For this, be sure to take a look at our article “Git Installation and Startup Commands“. When you follow the steps I have just mentioned, you will easily learn how to use GitHub.
How to Subscribe to GitHub?
There are several different websites that provide git repository services. Some are paid and some are free. We will use GitHub’s free membership for our project version control. We prefer GitHub because it is the first git version control system in this field. Let’s start by clicking on the address given below.
On the page that opens, click the SignUp button in the upper right corner. Type your own information in the 3 boxes on the screen that appears and become a member. The GitHub membership phase is that easy.
GitHub Developer Settings
Click on your profile picture and click on the Settings tab from the menu (“https://github.com/settings/profile”). When you pull down this screen, click on“Developer Settings” at the very end of the left side menu.

GitHub Tokens
On the page that opens afterwards, click on the“Tokens (Classic)” field under“Personal access tokens“.

Personal Access Tokens
Now let’s generate a token here. To do this, click Generate new token (classic) from the options on the right side as below. At this stage you may be asked for your Github membership password. This is requested for security reasons. Type your password and proceed.

Generate New GitHub Token
At this stage of our article on how to use GitHub, you will be asked to set authorization and access settings. In the field titled Note, write the name you will give to the token.
In the Expiration section, set the validity period. It is usually selected as unlimited (No expiration).
Here you just need to check repo and write:packages from the authorization options. You can also check all the boxes.

Finally, click the Generate Token button at the bottom and generate a unique token. This token will be shown to you only once. You will not be shown this code afterwards, so you should copy it and write it down. If you lose it, you can solve the problem by generating new tokens.
GitHub New Project Creation
Go to your Github Home page and click on the Repositories tab. Click on the New button at the top right. Name the owner field and the Repository name field next to it.
If you have a description, add it in the Description box. Select either Public or Private. Select Private if your project is private and you don’t want it to be seen by others. If it is an open-source project, select Public.
You may also want to create a Readme file to inform users. If there is license information, you can also add it in the relevant option. Click on the Create Reposity button and create your project.

On the page that opens, you will be shown the url link of your project in HTTPs form. Copy this link and go to the terminal screen.
GitHub ve Git Arasında Bağlantı Kurma
Return to the Terminal screen on your computer. Create a project as in our article “Git Installation and Startup Commands” and commit it.
Then run the following git command. Here you should type the url address of your own project.
git remote add origin https://github.com/omersahintr/yeniProje.git
GitGit Push Commands
The first time you run the -push command on Git, it will ask you for a token. We will write this one time. It will not ask for it again in subsequent push operations.
git push origin main
GitYou will see that the file is pushed under the project in the Repositories section on GitHub. Now your brunch, commit and all other files in your project have been successfully transferred to GitHub. We have largely given the answer to our question of how to use GitHub.
Pulling a Project from GitHub with Git Clone Command
It is possible to share your project with other teammates via GitHub. If you want to develop the project together, you can authorize your teammate for the project from the Collaborators tab on the Project Settings page.
Find and copy the URL link of your project under the Code button as you see in the image below.

After the authorization process is over, your friend will need to switch to the Git environment in the Terminal and run the following Git commands.
git clone https://github.com/omersahintr/MyTestProject.git
GitWhen you run this command and don’t get an error, a copy of your project has been exported to git on your friend’s computer.
This is definitely the best part of developing projects with Git. Especially the branch logic will be very useful here. Because our friend who joins the project later should do the development under a different branch so that the project is not jeopardized.
Thus, it will be merge with the main branch after the approval of the project manager.
Let our teammate open a branch called“dev1” and do the development under this branch. For this, he will need to type the following commands respectively:
git branch dev1
Gitgit switch dev1
Gitgit add.
Gitgit commit -m "version yenilendi"
Gitgit push origin dev1
GitIf the necessary token and GitHub project authorizations are done correctly, the project files in the branch named dev1 will be pushed to GitHub with the last command we wrote. If you see the following screen when you open your project on GitHub after this command, the process is successful.

After this stage, the project manager can merge the developments under different branches on GitHub or Git.
Git Pull (fetch)
The pull command contains the fetch function. The pull command also performs a merge operation on top of the fetch command function. First of all, version control is done. In other words, are you ahead or behind the project? this is determined.
git fetch
GitWhen you try to commit on the project, you will be shown how many steps (how many commits) behind you are.

As you can see in the picture, I am 2 commits behind the project. Since the merge process is done on the GitHub side, we are behind. Therefore, we need to synchronize with the pull command.
git pull
Git
As you can see, versions and commits are synchronized with GitHub.
Git Ignore
It is used to avoid sending unnecessary files or hidden files to Git and GitHub. For example, you don’t need to install python libraries here. With the -pipinstall command, other developers can install them on their own computers. Therefore, there is no need to send it to GitHub. We can achieve this with the Ignore command.
Here is our scenario, let’s create a file called hidden.txt.
touch gizli.txt
GitTo hide this file, let’s create a .gitignore file in the terminal:
touch .gitignore
GitAfter creating it, go to the project folder with Finder for Mac users and Explorer for Microsoft users. The .gitignore file may not be visible because we created a hidden file. Select Show hidden files mode from the file display options. For Mac users, you can use the key combination Command+Shift+. (dot) key combination when Finder is open.
Now that we can see the .gitignore file, let’s open it, type in the name of our hidden.txt file and close it. Let’s run the following commands respectively:
git add .
git commit -m "hiden files added"
git push origin dev1
GitThen, when we go to GitHub, we see that the hidden.txt file is not pushed.

When we enter the .gitignore file, you will see the name of the hidden.txt file.

There are ready-made github files for this process. As you can search on Google, GitHub also has such a project of its own. There are ready-made ignore templates for c++, C#, Python and many other projects. If you are wondering how to use GitHub professionally, you should definitely check this link.
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
GitHub – Python Git Ignore