PyCharm Integration with GitHub. Setting up Version Management for… | by Akshay Sinha | Medium

A quick introduction to github

If you want to be a python programmer, of course you have to work on project. Now most of the time you have to work in a team, of course you can make a solo project, but if you want to make a big project, you will be having multiple members. Let’s say you have 4 members working on one project.

Now what you think, how can you share the code? You are working on a project and 3 other members are working on a project, of course you have to share your files and of course you have to merge them somewhere on a machine. How will you do that?

There are two ways by which you can share your files –

  • Mailing Source File –  you can share your code in mail.
  • Dropbox – You can get a folder and everyone will put those code in this folder, thats how you can share files.

But it is not an efficient way. If you want to share your code, two things should be considered –

  • One thing is that you should have merge files.
  • The second thing is that you also have to maintain the version. And that can be done with the Git .

Now let’s see just a quick overview of GitHub such as what is github, why we use it etc. so let’s move to next.

How to install and configure Git?

To be able to use Git for PyCharm, do the following:

How to Create a Local Git Repository

To create a local Git Repository, follow the procedures below:

Changing the existing code

Now you can change this code as you want. I am adding following line to my code.

Now run this code, you will see your code is running and giving result but this code is only available on your machine. And that’s why currently version control is not maintaining. If you to achieve version control system, you need to say commit every time. So everytime you commit, you maintain the versions. But here is a new question arises – How to do commit?  

Committing the modified code

Right click on your project folder then select Git -> Commit Directory. You will get  following screen.

  • Now you have to add commit message. It should be a logical message because other people can understand it.
  • Now click on commit button. But yet it is not stored into remote server.
  • In github, here is two thing one is local repository and second is remote repository.
  • Everytime you commit, it will saved at the local repository that means if you go back to github website and if refresh it, you can see only the existing lines here
  • That means whatever changes you have done on your pycharm, it is not reflected in github website or remote repository.
Похожее:  Как поменять пароль на wifi роутере Ростелеком в домашних условиях на компьютере и телефоне

Configure git executable

Then go to File -> Setting  and in Version Control you have some options, choose the Git option to configure the git.

  • Now you need to give executable path of git.

Configure github account

Now go to GitHub

  • Here you first need to select Auth type as Password, by default it is Token.
  • Then you have to enter login and password of GitHub account and hit OK button.

Creating a new file on repository

Now your repository is empty, you have to create file here so click on Creating a new file option. This can be any file that means you can have a text file, python file, java file etc.

Now give a file name as you want. Here we are working with python file so we need to enter a python file. And write some code to this file. Here is an example.

Once you have entered your code then next thing you will do is to save this because if you don’t save it, it will not be showed.

But here is a different command i.e., Commit new file. Click on this.

How To Add Code To GitHub
How To Add Code To GitHub

Now you can see, you got your file here.

Now open this file, you will get your code here. But of course, you are not writing your code here. So to write the code you need some IDE. Here i am using PyCharm. So now the question is how will you pull this project on your PyCharm IDE. It’s very easy actually, you can simply do Clone or Download.

Похожее:  Личный кабинет Ровеб Онлайн

You can click on Download Zip, that’s way  you will Zip version. you can unzip it and open that project on PyCharm. That’s the first method, but here we will discuss the another method. So let’s move forward.

Creating a project on pycharm

Now create a project on pycharm IDE.

Creating repository

Now you have to create a repository. A repository contains all project files, including the revision history. So let’s see the below image.

How To Add Code To GitHub
How To Add Code To GitHub

In the above image, you can see a new  button is available. Click on it and you will be redirected to following page.

How To Add Code To GitHub
How To Add Code To GitHub

Now, you have to fill this form.

  • In Repository name, you just have to fill a name which you want to give your repository.
  • Next in description you have to fill some description about your repository.
  • Next you have to choose Public or private but here you have to choose Public because it is free and Private takes some charges.
  • Finally click on Create Repository button. You will get something like that.
How To Add Code To GitHub
How To Add Code To GitHub

Now you can access your repository using command line as well. Here you can see some commands are here.

Downloading github

To work with github, firstly you need to have download the github setup on your system.

Getting started to how to add code to github using pycharm

In this section, you will learn downloading and installing github on your system, sign up and login to github, creating repository in github and many more. So let’s move further.

Installing github

Once the download process have done, next you have to install it on to your system. So install it as you usually install any applications.

Pull the repository

To pull the repository,  you have to do following tasks.

  • Go to VCS-> Checkout from version control -> Git.
  • Here you have to insert url of your repository.
  • Then click on Test option.
  • Make sure you are logged in to your GitHub account.
  • Now the connection has been established with the url successfully.
  • Then hit the clone button. After this you can see your repository has been pulled to your PyCharm project.
Похожее:  Авангард интернет-банк личный кабинет: вход для физических и юридических лиц

Pushing the code on remote repository

Now if you want to store your code on remote repository then you have to do following tasks.

How To Add Code To GitHub
How To Add Code To GitHub

You can see one line is added to your code.

Setting up version control for collaboration projects

PyCharm is arguably one of the most popular IDEs used by developers on AI / Machine Learning projects. It is a full-featured IDE well suited for professional Python programming. It is available in 2 editions:

Good amount of information about these can be found at the below location:

However in this discussion our focus is to set up Collaboration projects using PyCharm and GitHub.

Signup and login to github

To use github, you need to an account on GitHub website. So go to official website of GitHub and create your account. Creating account on github is very simple, you just need to provide some basic informations and your account will be created.

Once the sign up has been done, next you need to have login to github for working further tasks.

Why github ?

  • It is always a good idea to keep project on github.
  • Because let’s say you are working on a machine and tomorrow you will have to go another city or anywhere and you got a new machine but at that time you have not your project.
  • But if you have kept your project on github then you can simply pull your project from github repository on your new machine. You don’t have need to use any online storage or pendrive or other stuffs.
  • The next reason to use github is that if you are working in a team, and you and your team members want to contribute same repository then git is a best option for you to work together. You don’t need email or other stuffs like that.

Now i hope you have much understanding about github. Now let’s move towards the main topic of this tutorial.

1 Звезда2 Звезды3 Звезды4 Звезды5 Звезд (Пока оценок нет)
Загрузка...

Добавить комментарий

Ваш адрес email не будет опубликован.

Adblock
detector