Setting Up Git and GitHub in PyCharm (Windows)

Asha AsvathamanAsha Asvathaman
5 min read

If you're just starting out with Git, GitHub, PyCharm, you might be feeling a little overwhelmed. You're not alone! This guide is for folks (like me!) who want to get things set up without feeling like they’re going to wreck their project in the process.

We’ll go step by step, from installing Git to pushing your first commit to GitHub so that the project you’re working on in PyCharm is safely and confidently backed up on GitHub.

Let’s get started! 🛠️💻

1. Install Git

If you haven’t installed Git yet, head over to git-scm.com and download the version for your system (Windows, macOS, or Linux). Run the installer; most of the default settings are totally fine.

Here are a few choices you’ll be asked about during installation and what I picked:

  • Default editor for Git: I chose Notepad. You can use any editor here because you'll still be running Git commands inside PyCharm.

  • Initial branch name: I chose to override the default and use main. Older repos often use master, but most modern setups now use main.

  • HTTPS transport backend: I went with Windows Secure Channel (better integration with Windows).

  • Line ending conversions: I kept the default — “Checkout Windows-style, commit Unix-style line endings.” This ensures your local files use Windows endings (CRLF) but commit as LF, which is standard.

  • Terminal emulator: I chose MinTTY, the default Git Bash terminal.

  • Default behavior of git pull: I left it as “Merge or fast-forward”, which is the safest choice if you’re new.

Once Git is installed, open a terminal or command prompt and run:

git --version

This confirms Git is installed correctly.


2. Configure Git (once, in any terminal)

Set your Git identity so your commits are properly labeled:

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Use the same name/email you use on GitHub.


3. Enable Git in PyCharm (Globally)

This tells PyCharm where Git is installed on your computer, so PyCharm knows how to use it across any project.

In PyCharm:

  • Go to File > Settings > Version Control > Git

  • In the “Path to Git executable,” make sure it points to the Git you just installed
    Example for Windows:
    C:\Program Files\Git\bin\git.exe

  • Click Test to make sure it works

  • Click OK


4. Connect your GitHub account to PyCharm

Go to:
File > Settings > Version Control > GitHub

  • Click the + button

  • Choose Log in via GitHub

    • Use your GitHub username/password or token

    • Or choose Login with browser

  • Once logged in, click ApplyOK


5. Enable Git for your PyCharm project

This tells PyCharm to turn Git on for this specific project that you are working on.

If your project isn’t already a Git repo:

  • Go to VCS > Enable Version Control Integration

  • Choose Git

  • PyCharm will now track changes with Git

You should now see the .git folder in your project and Git controls in the bottom bar.


6. Push exsiting PyCharm Project to Github (manually)

I have a project on Pycharm which I didn’t set up a git repo for. Thus I had to do the following:

  1. Go to https://github.com

  2. Click New repository

  3. Leave it empty:

  4. Click Create repository

  5. Copy the HTTPS URL, e.g.:

     https://github.com/yourusername/my-project.git
    

    Then open the terminal (bottom panel) in PyCharm:

     git remote add origin https://github.com/yourusername/my-project.git
     git branch -M main           # Optional: rename current branch to main
     git add .
     git commit -m "Initial commit"
     git push -u origin main
    

    Here you might get an error message like this:
    You’re trying to push or pull using the SSH URL, like:

    git@github.com:yourusername/yourrepo.git
    

    But you're seeing:

    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.
    

    To fix this, if you want to use SSH, you need to:

    a. Check if you have an SSH key:

       ls ~/.ssh/id_ed25519.pub
    

    b. If not, generate one:

       ssh-keygen -t ed25519 -C "your.email@example.com"
    

    c. Add your SSH public key to GitHub:

    Copy the key:

         cat ~/.ssh/id_ed25519.pub
    

    Then paste it into GitHub under
    Settings > SSH and GPG keys > New SSH key

    d. Test your connection:

       ssh -T git@github.com
    

    You might be asked for a passphrase. That should be you the passphrase you entered when you generated your key. If you can’t remember it, regenerate the key with a different passkey.
    You should see:

    Hi yourusername! You've successfully authenticated, but GitHub does not provide shell access.
    
  6. Now, push your existing PyCharm Project onto GitHub

  1. Use the bottom panel in PyCharm (Terminal tab), or go to:
    View > Tool Windows > Terminal
  1. Initialize Git(if not already done)

    git init
    
  2. Add your GitHub repo as remote. Use the SSH URL from your GitHub repo (looks like >git@github.com:username/repo-name.git)

    git remote add origin git@github.com:yourusername/your-repo-name.git
    
  3. Add and commit your project files

    git add .
    git commit -m "Initial commit"
    
  4. Push to GitHub

    git branch -M main      # Makes sure the branch is named 'main'
    git push -u origin main
    

Setting up Git and GitHub in PyCharm might feel intimidating at first, especially when you're worried you might "break something." But once it’s done, version control becomes a superpower. You can track your changes, collaborate easily, and push your work to GitHub to build your portfolio.

If you're just starting out, it's totally okay to fumble around a bit. Every confusing error message is just part of the learning. I wrote this post mostly for myself, as I was fumbling about too, and wanted a way to remember what worked. I hope this blog post helps you too.

Let’s keep learning, one commit at a time. 😊

0
Subscribe to my newsletter

Read articles from Asha Asvathaman directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Asha Asvathaman
Asha Asvathaman