Как открыть проект в pycharm из github
Перейти к содержимому

Как открыть проект в pycharm из github

  • автор:

Manage projects hosted on GitHub

You can clone a repository that you want to contribute to directly from PyCharm and create a new project based on it.

From the main menu, choose Git | Clone . If the Git menu is not available, choose VCS | Get from Version Control .

In the Get from Version Control dialog, choose GitHub on the left.

Log in to GitHub by doing one of the following:

If you have a token, click Use token , then paste the token in the Token field, and click Log In .

Otherwise, click Log In via GitHub .

Enter your GitHub credentials in the browser window that opens. If you have two-factor authentication enabled, you will be asked to enter a code that will be sent to you by SMS or through the mobile application.

Select a repository from the list of all GitHub projects associated with your account and the organization that your account belongs to.

In the Directory field, enter the path to the folder where your local Git repository will be created.

If you want to create a project based on these sources, click Yes in the confirmation dialog. PyCharm will automatically set Git root mapping to the project root directory.

Share a project on GitHub

You can add a remote GitHub repository for a project you are developing locally, so that others can view it or contribute to it.

Open the project you want to share.

From the main menu, choose Git | GitHub | Share Project on GitHub .

If you have already registered your GitHub account in PyCharm, connection will be established using these credentials.

If you have not registered your account in PyCharm, the Login to GitHub dialog opens. Specify your access token or request a new one with your login and password.

When connection to GitHub has been established, the Share Project on GitHub dialog opens. Specify the new repository name, the name of the remote , and enter a description of your project.

You can select the Private option if you do not want to allow public access to your repository for other GitHub users.

Click Share to initiate a new repository and upload project sources to it.

Jump to the GitHub version of a file

You can jump from PyCharm to the GitHub version of a file. PyCharm detects which branch is currently active as well as the latest revision of the file, and opens the GitHub copy of the selected file in the corresponding commit in your web browser.

Do one of the following:

Select Git | GitHub | Open on GitHub from the main menu.

Select a file in the editor or in the Project view, and choose Open In | GitHub from the context menu.

Select the file in the Project view, press Ctrl+Shift+A , and type Open on Github .

If you are signed in to GitHub, the remote version of the file will open in the browser.

Enter your GitHub credentials in the browser window that opens. If you have two-factor authentication enabled, you will be asked to enter a code that will be sent to you by SMS or through the mobile application.

If you are opening the GitHub file version from the editor, the file will be also automatically scrolled to the current line.

If the file points to more than one remote, you will be prompted to select the appropriate repository.

Create a Project from GitHub

Let PyCharm do the work to clone and setup a project hosted on GitHub.

To view this video please enable JavaScript, and consider upgrading to a web browser thatsupports HTML5 video

From repo to project in no time.

You need to evaluate a project. You need to get a fork. You’re always
getting code. Let PyCharm do the clone and make the project.

We all consume a lot of code. Alas, it’s a number of steps to get all that code from GH, into a directory, and opened in the IDE.

Let the IDE help out. If you have your GitHub credentials in your preferences, a few easy steps in the IDE will get you going.

First, in the PyCharm menu, choose VCS | Checkout from Version Control | Git . You can also skip the keyboard by invoking Find Action and speed searching for ch ve .

This brings up the Clone Repository dialog. In the URL field, speed search some letters in the repo name. The IDE looks across all the organizations that you are in, your personal account, and repos that you’re a collaborator for.

If the repo you want isn’t on GitHub, paste a URL in here.

In the directory field, supply the path and name of the directory this should clone into.

After answering the dialogs to get the repo and open in a window, your project is ready.

To view this video please enable JavaScript, and consider upgrading to a web browser thatsupports HTML5 video

Get started with an existing repository from GitHub in PyCharm

When working on programming projects, version control is very important. Git is one popular software that can be used for version control and collaborative work. When working on projects in PyCharm, Git can be integrated into the project so that you can do your work on PyCharm and once tested , then you can publish your work over the internet for the outer world to interact. It also protects your work in case anything happens to your local environment. Jump in !

Perquisites:

  • You should have PyCharm installed on your machine.
  • You have authorized PyCharm to communicate with your git repo through your login credentials or with token.

You can go to Settings -> Version Control -> GitHub

Or Go to Settings in GitHub . Then Developer Settings -> Personal Access Tokens

Now Let’s go to GitHub and create a repository

Let’s add a python program in this repo .

Now we will clone this repository into PyCharm and start our work there . Click code . Copy the HTTPS link .

Go to PyCharm and navigate to VCS to clone the repository

Paste the URL of the git repository , you want to clone

Now you can see the project on PyCharm .

Let’s edit something in this file and also add a new file

I added a file hello_in_japanese.py . It’s prompting me , do you want to add it to your local git repo. Let’s add it and then commit our change by pressing Ctrl+K

Before committing , we can review the change by using diff (two blue arrows)

  • we added an additional line to the existing file
  • we added a new file

Write some messages before committing

We are here now and yet to push our changes to remote repository

Status of logs

Observe the state of remote . It has only got record logs of the commit when we created the file when we created the repository in GitHub

State of local repo is at this stage as we added a new file and changed to existing file. It’s one commit ahead of the remote.

Push

Let’s now push the changes to remote by Ctrl+Shift+K and go to our remote github repository.

Now you can see the changed file and new files both are visible.

I will dive into , how can we do collaborative work between multiple branches using Git. Stay tuned.

Как открыть проект в pycharm из github

2) Go to “Version Control” –> “GitHub” . Enter your github details.

If you are using enterprice private github provide the URL for the same; like mycrop.devel.github.com .

You can select the auth type as “Password” or “Token”.If you select the password you can etenetr your GitHub username and password.

Click on the “Test” button. If the URL, username and password is correct you will see the following screen. If it is not please check your URL/usernamw/password.

3) Click “Ok” the pop-up and bottom.

Click on the “…” near the “Test” button. It will open a new pop-up window. If you are in Windows browse to “Program Files (x86)” in the case of 64 bit systems else “Program Files”. Go to “GitHub”–> “bin” and select “git.exe” and click “Open”

In systems like Ubuntu/CentOS/Fedora or MacOsX this step is not required.

5) Click on “Test” button. If the correct version of the “git.exe” file is selected it will show test successful message. Else you might not have selected the right git.exe file.

6) Click on the “Apply” and then “Ok” button. This will configure the “GitHub” with PyCharm.

Checkingout Code and Commiting Code

1) From the “VCS” menu go to “Checkout from Version Control” –> “GitHub”

2) It will open a new pop-up window. Enter the complete remote repository URL in the “Git Repository URL:”

Enter or Browse to a dierctory where you would like to store the cloned repo in the “Parent Directory”

You can pride a dierctory name in the “Directory Name:” . Mostly this will be the rempte Git Repo. If you wish chnage the same. Else let it be the same.

3) Click on the “Test” Button to check GitHUb connectivity. If the connection is successful it will show the following window.

If there is error check the configurations for GitHub.

4) Click “Ok” and it will promt for confirmation. Click “Yes” on the new pop-up window.

5) Once the ckeck-out is compleated it will ask for confirmation wheather to open in the same window or open a new window. Click on the same window opetion and “Ok” button.

6) Now add a new file

Once you create the file it will ask wheather the file has to be added to version controll. Click “Ok”.

7) Now add some content to the new file. Go to “VCS” –> “Commit”

8) It will open a new pop-up . Add a commit message in Commit message box. Click on the Commit button

Once the commit is done a small green pop-up will apper in the bottom of PyCharm.

9) Now we have to push it to master. Rightclick on the modified file . Go to “Git” –> Repository –> click “Push”

PyCharm Version Control and git complete tutorial for beginners

replace «My name» and » [email protected] » with your values which will be associated as git account values.

install git for linux

Adding git to Ubuntu and Linux Mint is really easy just by a single command:

Default installation on Ubuntu 18.04 and Linux Mint 18 is:

PyCharm git operation

All version control operations like:

  • commit
  • pull
  • push
  • remote

are located in main menu — VCS

For example checking for remotes — linked projects with git can be found:

  • VCS
  • Git
  • Remotes

You can change, delete or add you remotes from the open dialog.

If you work with Version Control you will want to show tool bar Version control by:

  • ALT + 9
  • or from menu:
    • View
    • Tool Windows
    • Version Control
    PyCharm git commit

    In order to commit your changes you need to have remove set up.

    • go on view Version Control — ALT + 9
    • Local Changes
    • Select the Changelist — i.e. Default
    • Right click
    • commit — CTRL + K
    • Select what to be commit
      • you can commit everything or select only one / several files
      PyCharm git push

      You can push using the previous section or to push later by using:

      • Menu
      • VCS
      • Git
      • Push — CTRL + SHIFT + K
      Pycharm git clone

      If you want to clone a repository from github.com you can do it by these steps:

      • File
      • New
      • Project from Version Control
      • Git
      • URL — enter the remote URL address
        • for example (Book Think Python) — https://github.com/AllenDowney/ThinkPython.git
        • only if you used it for first time

        By default you will clone the full repository and will set up the master branch. If you want to change the branch you can clone the address of the other branch.

        Pycharm git checkout

        If you want to change the current branch or preview older versions (previous commits) you can do it from

        • go on view Version Control — ALT + 9
        • Log
        • Select Revision
          • you will see all revision with user and dates on left
          • on the right you will see all changes
          Pycharm git pull

          If you need to pull changes from other users using git can be done by:

          • Menu
          • VCS
          • Git
          • Fetch

          This will check the remote repository for any changes. In case you need changes you will see them in the Version Control window — ALT + 9 . You can view the new modifications in tab Log. If you want to pull the changes then you can do it from:

          • Menu
          • VCS
          • Git
          • Pull

          After successful pull request you will see new tab Update Info. There are all changes divided in three different categories:

          • Pull(12 items)
            • Updated from server(12 items)
              • Updated(3)
              • Created(7)
              • Deleted(2)

              PyCharm Version Control

              Version Control window can be shown by ALT + 9 or:

              • Menu
              • View
              • Tools Windows
              • Version Control
              Local Changes

              The first tab is named Local Changes inside you can find all your changes separated in changelists. You can do several operations from this tab:

              • commit change — CTRL + K — Saving your changes in a repository. Git add adds a change in the working directory to the staging area.
              • revert — CTRL + ALT + Z — This will revert (remove, give up) your local changes and will return the older files versions.
              • delete — completely delete the file from this project
              • Move to another changelist — you may want to maintain several different changelist. This is useful in case of project specific files like IDE, DB settings etc
              • ignore — in case that the file is not added to VCS and the remote repository you can ignore files or folders. Several technical folders need to be ignored in order to avoid problems. You can ignore also test directories or big files.

              In this tab you can see all revisions and code changes. You can checkout to another version / branch. Compare with previous versions by selecting a file and pressing CTRL + D . New window will be open with two version of your code.

              Console

              If you want to know what commands are executed or simply check your daily activities related to git. You can visit tab Console. Inside you will find the actual git commands with all parameters. For example:

              Update info

              The last tab Update info will be shown after successful pull. Inside you can find information about all pulled changes:

              • Updated(3)
              • Created(7)
              • Deleted(2)

              Show git information

              How to check the current user name or email:

              To list everything in the git file:

              [email protected]
              [email protected]
              core.autocrlf=input
              core.repositoryformatversion=0
              core.filemode=true
              core.bare=false
              core.logallrefupdates=true
              remote.origin.url=https://github.com/xxx/xxx.git

              Setup proxy and Git

              Setup by command

              The easiest way too add proxy to your git configuration is by:

              • proxyuser — proxy user ( you can check the proxy configuration Windows 10 — Settings/Network & Internet/Proxy or ubuntu — System/Preferences/Network Proxy)
              • proxypwd — proxy password
              • proxy.server.com — proxy server
              • 8080 — proxy port

              Disable git proxy by

              Setup by file

              If the command line is not your favorite way of working, you can just edit .gitconfig

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

Ваш адрес email не будет опубликован. Обязательные поля помечены *