How to use Git and GitHub with PyCharm | Quick Tutorial on basics

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone thanks for clicking on this video uh this tutorial is going to be about how you can use kit in pycharm and since most of the videos on youtube about git are mainly using terminal to get familiar with the basic commands of git i'm going to use pycharm and show you the graphical user interface that it provides for git which is very useful and makes life a whole lot easier so i'm going to show you how you can pull project from your remote repository and then make changes to it push them back and generally how you can track your files and modify them using pycharm's git gui so first of all we're going to go to github and create a new remote repository and in order to create a new remote repository you just have to click on this top right hand corner plus sign and then choose new repository i'm going to name this demo and write some random description so this is our demo project i'm going to leave it public and i'm not going to add files here we are going to add them locally and just press create repository so from here we don't have anything in our project currently but we're going to clone this to our local repository using pie chart so if we go ahead and open pie chart we can see that we have three options we can either create a new project open already existing project or get from version control system and since we are using a remote repository we are going to click on this button and then it asks for the url of our remote repository so we can copy that from here so ssh selected we can just copy this link and then paste it to our url tab and then just press clone so now our project has been opened in pycharm and we are going to use pycharm to add some files to our project and then we are going to push them back to our remote repository so first of all i'm going to right click on our project file and then go to new and then choose file and i'm going to create a readme file i'm going to use the md extension which stands for markdown and it's just a way of formatting your text files so every project in general needs to have a readme file which gives a general understanding of what project is about and i'm just going to create one heading here so this is a git tutorial the content of these files is not relevant for this video since we are just going to use these files to demonstrate git commands so from here we can save our file and as you can see here it is currently marked in red and that means that git is not tracking uh this file and if we want to add this file to git or in other words add this to staging area we we can do that by right-clicking on our file and then going to git and then pressing add the shortcut for this command is ctrl alt a so you can use that if you want and as you can see it turns green which means that that git is currently tracking our file so from here i'm going to add one more file which is going to be a python file let's name this main and as you can see here pycharm by default asks us if we want to add this file to git but since we can't do that manually later i'm just going to skip this option but you can use it if you want to add this file to the staging area from the beginning in this python file i'm just going to write one line let's print something so let's for example print hello kit and also we need to configure the python interpreter for our project and if your interp and if your python interpreter is not configured you can do that by going to file and then settings and then python interpreter and from here you can choose add and then from here add a python interpreter that you like and then press ok so now that python interpreter has been configured we can actually run python files in our pycharm environment so i'm just going to press run then main and as you can see it prints hello git so from here i'm going to add this file to our staging area so i'm just going to right click on it and then go to git add and if we want to see our files that are ready to be committed we can go to this commit tab right below the project tab so from here under the changes you can see that we have two files the main file and the readme file we have just added and in order to commit our changes we just have to mark them and then write our commit message so i'm just going to write this is our project initial state and from here we have two options we can either commit or we can commit and push to our remote repository at once but i'm just going to commit for now and in order to see our commit we can go ahead and click this git tab on the bottom left corner so in our current master branch which is the default branch you can see that we have made one commit and if we want to push these changes to our remote repository we can just use this green arrow on the top right corner to push so it shows which files are going to be pushed to our origin or in other words to our remote repository so we can go ahead and press push so now so now that our changes have been pushed to our uh origin master branch we can go ahead and refresh our page in the github and as you can see here the two files that we have just added locally appear in our remote repository so now that we have added those files to our remote repository i am also going to show you how you can pull the changes from your remote repository uh to your local system so for example if we create a new file in our remote repository by adding file here and i'm going to add a new text file so this is going to be test.txt and i'm just going to write something like this is a remote file and then commit this new file so now we have this file in our remote repository but we don't have it locally and in order to update your current local repository you you can just go ahead and click this update button here and as you can see here now the test.txt file also appears in our local repository okay so the next thing that i want to cover is how you can add a git ignore file so in case there are files in your repository that you don't want kids to track you can add them to the git ignore file and they won't be tracked by git so in order to do that i'm going to go to my demo file demo folder and then add a new file so let's say that we want to ignore all the pdf files that are currently in our project so i'm going to create a new pdf file and let's name it random.pdf and in case we don't want git to track any kind of pdf files we can just go ahead and click on this file and then go to git and then add this to git ignore so this will create a git ignore file and i am going to add this to my staging area right from the beginning and currently it only ignores the random.pdf file so only this pdf file but if we want to ignore all the pdf files that will be created in our folder we can just replace this random with the asterisk sign and asterisk basically means anything dot pdf so any kind of pdf file from now on will be ignored in our project so from here i'm going to commit the changes that we have currently made i'm going to name this configuring kit ignore and then commit and then commit this to git so from here if we go ahead and create one other pdf file let's name it file dot pdf the git just ignores it and doesn't tell us to add this to staging area or do anything we did and this git ignore file is not only about just ignoring some files you can also include a whole folders or repositories and tell a git to ignore those folders for example and the last topic that i want to cover is about branches how do we create branches and work uh on a different branches and then push them to our remote repository so in order to create a new branch you just have to click on your current working branch and the head pointer currently shows that you are working on the master branch so in order to create a new branch uh from your current master branch you have you have to you have to right click on it and then choose new branch from the selected and then give it a name let's name it development branch and the branches if you don't know just allow you to work independently uh like create different workflows and which will not affect one another so the changes that we make on the development branch won't affect for example the changes on on our master branch but if there are commits in our development branch that we make in the future and we want them appear in our master branch or our main branch we can do that by merging those branches together so now that we have created this development branch we are now working in it so we can go ahead and make some changes to our development branch for that i'm going to click on our project folder and then create a new file and let's name this dev file let's add it to our staging area and then go ahead and commit the changes and let's name this making changes to that and go ahead and commit so as you can see here we have made the new commit to our development branch but if we go to our master branch it doesn't appear here but if we want to make these changes also appear in our master branch we can make it happen by merging those branches together so to do that we have to first of all check out or switch to our master branch and we do that by right clicking on our master branch and then going check out and after that we can right click on the development branch and then select merge selected into current so this will apply all the changes that we have made to our development branch into the master branch and from here we can go ahead and push all the changes we have made to our remote repository so from here if we go to our github repository and check it we can see that all the files appear here including the dev file because we pushed it from our master branch but we can see that we currently have only one branch in our remote repository and in order to fix it we have to go back to our development branch check out to our development branch and then push this to our remote repository so from here if we go back to our remote repository and refresh it you can see that we now have two branches development branch and master branch appear also in github so that was all that i wanted to cover in this video thanks for watching if you made it this far and in case there are other guitar related topics that you want me to cover you can tell me that in the comment section thanks for watching and goodbye
Info
Channel: YourCodeTutor
Views: 91,178
Rating: undefined out of 5
Keywords: how to use git with pycharm, clone git to pycharm, connect github to pycharm, git and github with pycharm, git tutorial 2021, git github 2021, git, github, create repository on github, clone repository to pycharm, pycharm and git, how to use git in pycharm, use git in pycharm, use git inside pycharm, pycharm
Id: -_g3QITLaQA
Channel Id: undefined
Length: 15min 38sec (938 seconds)
Published: Fri Aug 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.