How to commit a partial file (hunks) to git in pycharm

前端 未结 2 1274
情深已故
情深已故 2021-02-11 22:01

I\'m a heavy Eclipse PyDev + EGit user and looking to switch to PyCharm. In Eclipse, I can choose to add only certain hunks/lines of a file to the git index, the same as using <

2条回答
  •  暖寄归人
    2021-02-11 22:30

    PyCharm manages this through change lists. Here is an example.

    1. We create a new change list from an existing one (one that we've already created, or the default changelist).
    2. We make a couple of changes and hit VCS -> Commit Changes
    3. In the diagram below at {1}, you can see that the changelist is set to Default, and in {2} you can see the actual change. Right click on {2} and select the change.

    enter image description here

    Now, say we want to commit only this change. We can do this by adding it to a new changelist, by clicking on {3}, and this will pop up:

    enter image description here

    Since we don't have a new one, let's just create a new changelist using the dialog box. And then let's change the currently selected changelist to New Changelist:

    enter image description here

    Notice that there is only one file, with one change, just like our changelist. How about we add a few things from the default changelist to the new one:

    enter image description here

    Now, let's head back to the New Changelist:

    enter image description here

    Now that we're done with our selective changes, press Commit. After this, we can push:

    enter image description here

    I pushed to bitbucket, so let's see the changes:

    enter image description here

    As you can see, only the stuff in the New Changelist was added.

提交回复
热议问题