You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PyCharm中Git显示旧项目提交日志,如何获取全新提交日志?

Fixing Old Git Commit History in a New PyCharm Project

Hey there! I’ve run into this exact issue before—when you set up a new project in PyCharm and link Git, it somehow pulls in commit history from an old project. Let’s get your project a fresh, clean Git history in no time.

Step 1: Confirm the Problem

First, let’s make sure we’re dealing with a linked old repository:

  • In PyCharm, check the bottom Git panel (click "Log" to see if old commits are showing up)
  • Or open a terminal in your project root and run:
    git log --oneline
    
    If you see commits from your old project, we need to wipe the existing Git data.

Step 2: Wipe Old Git Association & Start Fresh

Here’s how to completely reset the Git setup for your new project:

  1. Close PyCharm first—this avoids any cached Git state that might cause issues.
  2. Delete the hidden .git folder in your project directory:
    • On Windows: Enable "Hidden items" in File Explorer, then find and delete the .git folder.
    • On Mac/Linux: Open a terminal, navigate to your project root, and run:
      rm -rf .git
      
  3. Reopen PyCharm and reinitialize Git:
    • Right-click your project root in the Project sidebar → Go to Git → Select Initialize Repository.
    • Confirm the repository location is your new project’s root folder.

Step 3: Make Your First Fresh Commit

Now that Git is set up cleanly, create your initial commit:

  • Right-click the project root → Git → Add (or use git add . in terminal)
  • Go to Git → Commit File...
  • Enter a message like "Initial commit for [Your New Project Name]" and click Commit.

Check the Git log again—you should only see this new commit, no old project history!

Bonus: Double-Check for Old Files

If you accidentally copied files from your old project into the new one, make sure to delete any irrelevant files before committing. This keeps your project and Git history clean.

内容的提问来源于stack exchange,提问作者Drearo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:23:00