Git On Pycharm - WheatonCS/Lexos GitHub Wiki
This guide explains how to use Git while working on Pycharm.
Warning: This is not a tutorial on Git
, this will just show you how to use Git while using PyCharm.
The following demonstrates the the process of using Git from PyCharm.
The issue needs to have a readable and detailed description of:
- The problem or feature
- The proposed way to solve the problem or the proposed implementation
You don't have to finish writing the issue all at once.
But you do need to finish the proposal before moving on to the code. Here is the reason:
- Everyone can read your issue, but very few people can read your mind.
- People can make suggestions on your issue to help you implement the feature.
- People can also make suggestions when your proposal conflicts with other's work.
- It is always good to make a plan first.
See: Branch.
- The branch you create needs to start with
feature/
orbugfix/
so it is understandable to the other users and the Admin - The branch needs to end with the issue number you need (Find your issue at: Issues)
Here is an example branch name: feature/matrix_ajax#494
Always:
See: PR
Just provide brief description and then wait for the Admin to review your request!
see: Checkout
Again, don't forget to:
You can create a pull request for this branch, or wait for the branch-creator to create the pull request
See PR
The following is an image tutorial on basic Git operations on Pycharm
You can commit your code by clicking the green up
button oin the top right corner of Pycharm IDE, or use Ctrl+K
.
Pycharm will then display this window:
Before you commit:
- Check the
optimize import
andperform code analysis
on the right. - Write clear commit message.
- The first line of the commit message is a summary of the commit, do not use more than 50 characters on the first line.
- Only select the file you need to change.
- Commit as often as possible.
After you finish your commit:
- If you have internet access, you can commit and push at the same time by mousing over the commit button on the bottom left corner of the window and selecting
Commit and Push
: - If you only want to commit, you can click the
Commit
button on the bottom left corner of the window:
NOTE: The push operation requires internet access.
In Pycharm you can open the Push
window via Ctrl+Shift+K
You will see all the commit messages on the left, and all the changed files on the right.
Just click the Push
button on the bottom right corner of the window to push.
Warning: If you want to force push (you probably shouldn't), check with the Admin first!
While you are working on your branch, you want to always keep up with the work of others.
This requires the branch you are working on to be up to date with master
branch.
It is recommended to merge as much as possible, you should merge after every push.
To merge the code from the master
branch to your branch, you need to:
- Click the
Git
on the bottom right corner of the status bar. - Click the
origin/master
branch underLocal Branches
, Not themaster
underRemote Branches
. - Click Merge.
If this does not work you may have to do a manual merge, see the next section for more details.
Sometimes when you push (pull) or merge,
you will encounter a Merge Conflict
, which requires you to do a manual merge:
Select your file and then click the Merge...
button:
- The brown line indicates conflicts.
- On the right is your file.
- On the left is another user's file.
- In the middle is the merge result
You can click the little >>
or ×
next to the file to accept or reject the changes. (Or you can click either the Accept Left
or the Accept Right
button in the bottom left corner of the screen to accept the other user's file or to accept your file)
In this case I accepted (>>
) my change and rejected (×
) the other user's changes.
Now just click the Apply
button in the bottom right corner to finish merging your current file with the master branch.
- Click the
Git
button on the bottom right corner of status bar. - Click the
New Branch
button at the top of the window that appears. - Give your branch a branch name.
- Now you are in your new branch!
- Click the
Git
button on the bottom right corner of status bar. - Click the branch you want to checkout (in this case the local
master
). - Click the
Checkout
button - You are now in the branch you selected to checkout.
- Merge
origin/master
into current branch, see Merge - Press
Ctrl+Shift+A
and then search forpull request
. - Fill in the description and title. Make sure the Base branch is
master
- Select the
Ok
button in the bottom left corner of the screen