GitHub
To be able to retrieve data from a repository hosted on GitHub, or share your projects, you need to register your GitHub account in PyCharm.
If you do not want to specify your credentials each time you sync with a remote, or push your commits, you can configure PyCharm to save your account information (refer to Configure a password policy).
Register an existing account by signing in to GitHub
- Press Control+Alt+S to open the IDE settings and then select Version Control | GitHub .
- Click .
- Select 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.
Register an existing account with a token

- Press Control+Alt+S to open the IDE settings and then select Version Control | GitHub .
- Click .
- Select Log In with Token .
- Do one of the following:
- If you already have a token, insert it in the Add GitHub Account dialog window:
- If you want to obtain a new token, click Generate . 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. In the token generation page, make sure that the repo , the gist and the read:org scopes are enabled (refer to Understanding scopes). Click Generate token , copy the token, and paste it into the Add GitHub Account dialog window.
- Click Add Account
See Creating a personal access token for more details on GitHub tokens.
Update an expired token
- When your token expires, you see the following warning when trying to push changes to the GitHub repository:
Click Use Token . - Do one of the following:
- If you already have a token, insert it in the Log In to GitHub dialog window:

- If you want to obtain a new token, click Generate . 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. In the token generation page, make sure that the repo , the gist and the read:org scopes are enabled (refer to Understanding scopes). Click Generate token , copy the token, and paste it into the Log In to GitHub dialog window.
- If you already have a token, insert it in the Log In to GitHub dialog window:
- Click Log In
Create a new GitHub account
- Press Control+Alt+S to open the IDE settings and then select Version Control | GitHub .
- Click .
- Select Log In via GitHub .
- In the browser window that opens, click Create an account and complete the registration process on GitHub.
- Return to the PyCharm settings, click Cancel , and then repeat steps 2 and 3.
- Click Authorize JetBrains in browser.
Manage multiple GitHub accounts
You can use multiple GitHub accounts in PyCharm: for example, a personal account to work on an open-source project, and a corporate account for your main job.
- Press Control+Alt+S to open the IDE settings and then select Version Control | GitHub .
- Use the button to add as many accounts as you need.
- (Optional) To set an account as a default one for the current project, select it and click . If a default account is set, PyCharm will not ask you to select an account you want to use when you share your project on GitHub, rebase a fork, create a pull request, or create a gist.
If you cannot view pull requests in the IDE, or you get an error when you log in to a GitHub account and perform any git operation, refer to the Operations Against a GitHub Repository Are Failing article for troubleshooting tips.
Настройка GitHub в PyCharm

Ставим. Везде, где был выбор, все оставил по умолчанию. И готово!
Возможно ваш PyCharm еще не тот путь видит на файл Git. Чтобы это исправить, заходим File-Settings-Version Control-Git и исправляем там путь. У меня это: C:\Program Files\Git\cmd\git.exe
Оффтоп вместо рекламы: Сарафан: поиск мастеров, если вдруг вам нужно вызвать мастера для решения бытовых вопросов
Как добавить Git в Pycharm
В какой-то момент, после долгих мучений с сохранениями и миграцией проектов, любой начинающий программист задается вопросом как добавить git в pycharm для того, что бы этот проект загрузить на GitHub.
Скачать и правильно установить Git
- Скачиваем Git на официальном сайте;
- Устанавливаем на свой рабочий ПК (все можем ставить по умолчанию, только в одном месте изменить, где нам нужно отметить: Override the defaul branch name for new repositories)

Далее, после установки Git и для корректной его работы, не забываем перегрузить ПК.
Как добавить git в pycharm
На самом деле, здесть тоже все просто, естественно сам Pycharm у вас должен уже быть установлен! Если еще нет, смотрите здесь как это правильно сделать.
- Запускаем PyCharm и создаем проект;
- В меню находим пункт VCS -> Create Git Repository
- В окне с проектами выбираем тот, который нам нужен (если мы открыли с нужного нам проекта, то нажимаем ОК) и нажимаем ОК;

Как создать commit
Итак, после того как мы создали репозиторий, в блоке файлового менеджера файл main.py стал красным, меню VCS пропало, вместо него теперь пункт меню GIT, и справа вверху появилось 2 стрелочки, синяя вниз и зеленая вверх, а между ними зеленая галочка:
Как добавить git в pycharm
Вот как раз цвет имени файла и говорит нам о том, что этот файл не находится под контролем Гита, т.е. не выполнен коммит.
Что бы его выполнить, необходимо нажать на зеленую галочку справа, и откроется дополнительное окно с выбором файлов, которые необходимо отправить в commit, выберите эти файлы, т.е. установите галочки в соответвующие чек-боксы, потом обязательно дайте название вашему коммиту, т.е. впишите информацию о данной версии программы в поле Commit Message и нажмите на кнопку Commit:

Если все сделали правильно, через несколько секунд слева внизу PyCharm будет сообщение о том, что столько-то файлов закомичено, а название файла проекта, т.е. в нашем случае это main.py становится серого цвета:

Подведем краткий итог:
- Cкачали и установили Git;
- Мы разобрались как добавить git в pycharm;
- Как выполнить commit.
Как подключить репозиторий GitHub к PyCharm?
Заранее извиняюсь если глупый вопрос, я только учусь программировать.
Столкнулся с тем что не могу подключить PyCharm к своему приватному репозиторию на GitHub. При этом, свои открытые репозитории хорошо подключаются.

Вот мои репозитории на GitHub:

А вот в PyCharm:
Нет репозитория «Hamsterkauf / chatbot_django»
Подскажите, в какую сторону копать?
- Вопрос задан более двух лет назад
- 5270 просмотров
1 комментарий
Простой 1 комментарий