PyCharm version Control
PyCharm integrates most of the popular version control systems, such as Git, Subversion, Mercurial, Perforce, to The most commonly used Git as an example
Pycharm associated git
In File - > settings, find Version Control -> Git as follows As shown in the figure, configure the path of the local git.exe
1. Import GitHub project and configuration span>
1. Method 1
Click VCS in the menu bar - > Get from Version Control
2. Method 2
Click Get from VCS on the welcome page, if you are in the project, you can click File- > close project Exit to the welcome screen
and then configure the relevant content, as shown in the figure below.
After configuration, click Clone
After the import is complete, enter the project. We will find that the CSV in the menu bar is gone, replaced by Git
**Commit: **Submit the code to the local warehouse
**Push:**Submit local warehouse code to remote Git warehouse< /span>
**Pull:**Synchronize the remote Git code warehouse to the local warehouse< /span>
**Branches:**View all branches of the project
**New Branch:**Create a new branch
**Show Git log:**View Git historical operations
2. Example
Modify a file in the project, then click Git - > Commit, the shortcut key Ctrl + K, the following interface will appear
If you click Commit, you need to push again, or click Commit and Push directly Finish.
Push path in Git-> Push, shortcut key Ctrl + Shift + K
After clicking Push, a verification window will pop up
Clicking Log In via GitHub will bring up a validation window in your browser. Click Authorize in GitHub.
The current modification record can be viewed in Show Git Log
3. Difference comparison
Method 1:
If you want to compare the difference of a py file, or compare it with the historical version , you can right click on the file and select Show Diff, Compare with ...
Method 2:
There is a green line on the left side of the modified code, indicating that this code is Modified
Right click on the green line,
Select Annotate with Git Blame to see all history.
Then select what you want to view, right click Show Diff to view the difference .
Pycharm Practical Tips
< span style="letter-spacing: 1.5px;"> As one of the most commonly used IDEs for Python development, Pycharm is not only compatible Well, and the functions are quite rich, such as debugging, syntax highlighting, smart prompts, etc. It also supports web development frameworks such as Django, etc. After you are familiar with it, the development efficiency is quite high.
But for novices, Pycharm is rich in functions and is also a double-edged sword. It is inevitable that you will be confused when you see a bunch of English interfaces.
It doesn't matter, today I will teach you 11 of the most commonly used skills of Pycharm, as well as some commonly used shortcut keys of pycharm, so that you can Quickly get started with Pycharm, the most commonly used IDE in Python development.
1. Common tips
1. Set code font
Click on "File" in the upper left corner, select "Settings" and enter "font" Find "Font", set the number in "Size", the default is 12, it is recommended to be 18 or 20.
2. Set menu interface text size
This is a little different from the above. The above is to adjust the text size of the code, but it does not change the text size of the menu interface. Then you can Need to adjust the text size of the menu interface, click "File" in the upper left corner, select "Settings", enter "font", find "Appearance", after ticking "Use custom font", you can use it in the following Choose the font size you like in Size.
3. Quick multi-line comment or cancel multi-line comment
Although we can use "#" to make single-line comments when writing code, if there are multiple lines of code that need to be commented, then It is a bit troublesome to type "#" line by line. Here we can use the mouse to select multiple lines of code, and then press Ctrl+/ to comment on multiple lines of code, and at the same time cancel the comment of multiple lines of code.
4. Code formatting, standardizing code
When we first started writing code, it is inevitable that there will be problems with irregular code writing, although it does not affect the operation , but the readability is relatively low, especially when you read a long and irregular code, you will experience the pain. This problem is actually easy to solve. We only need to find "Code" in the menu bar after writing the code, and click "Reformat Code" to automatically standardize the code.
5. Quickly modify the same variable or class
When writing code, we often have to define many variables or classes. When writing code, variables or classes may be in multiple The place is used, so if we need to modify a certain variable or class in the code, do we modify it one by one?
Of course not, we only need to select the variable or class that needs to be renamed, right-click and select Refactor from the pop-up option, and then click Rename to make global modifications. For example, if I want to change all "n" variables in the code to "i", then the operation is as follows:
6. Quickly find variables, functions, etc.
When our code is relatively long, it is very troublesome to swipe from beginning to end to find a certain variable or function , at this time we need to use the shortcut key Ctrl+f for quick search. For example, I want to find out where the function "runGame" is used in the Snake project, then we only need to use Ctrl+f to call up the small window, and then enter the keyword "runGame" to search to every occurrence of "runGame" in the code.
7. Find modification history
When writing a project, it is often modified, and sometimes it takes several days to complete it, but if we open the I want to add a new function to pycharm. I don’t want it anymore after doing it for a long time. I want to get back to yesterday’s version, but it’s been a long time, and I can’t get it back even if I undo it. What should I do? At this time, you need to find the modification history. Pycharm is still very user-friendly. Every step of the change you make, it will save the history for you. Just right-click the file and you can find all the changes in the Local History. historic version. Take the simplest example. For example, my current code has an extra function to "prompt 'execution end' after the execution is completed". I don't need it, but I can't undo it now. What should I do? At this time, we can go to Local History to find the historical version and change the existing version back to the historical version. (Except for direct deletion, direct deletion is not our purpose)
8. Install and configure pippy domestic source
When we use pip to install some resources, pycharm defaults to download foreign resources for us, sometimes The installation failed due to problems such as the network. In fact, we can configure it to download domestic resources and it can be solved.
The most common way is to go to the open source mirror station of Tsinghua University to download. We only need to set it in pycharm, and it will be I went to China to download it myself.
Setting method:Click "File" in the upper right corner→click "Settings"→find under Project "Python interpreter" → click "+" → click "Manage Repositories" → click "+" → enter the address of the open source software mirror site of Tsinghua University: https://pypi.tuna.tsinghua.edu.cn/simple
9. Installation package
When writing code to achieve certain functions, we often need to install software packages, so it is necessary to install packages for pycharm Mastered.
How to:
Click "File" in the upper left corner → click "Settings" → find "Python interpreter" under Project → click "+"→ Enter the name of the package you want to install, such as "pygame", and then click "Install Package" below to start the installation. After the installation is complete, you can use it.
Note that it can only be used after the installation is complete, and there will be a download progress bar at the bottom of the interface:
10. Debug
It is easy for us to report errors when writing code, but sometimes it is difficult for us to see the problem on the bright side , then we need to debug at this time, which is also a commonly used technique in the development process.
How to debug? Click on the left side of the line of code that you think may go wrong, and a red dot will appear. We call it a breakpoint. As long as the program runs to the breakpoint, it will automatically stop. After setting the breakpoint, we right-click and select "Debug project name" to run, and then we get to the running interface, we walk step by step, and at the same time we can see the changes in the values of some variables inside.
11. Set a personalized background?
This is an additional function, you can set a personalized background for your pycharm, depending on your personal needs, you can set it if you want After all, it is tiring to read English and numbers when writing code, and it is okay to read something else occasionally. For example, my pycharm, haha! !
How to set it:
①Open pycharm, click File, and select settings.
②Click Appearance under the Appearance & Behavior option, and click Background Image.
③ Click on the place with "..." in the upper right corner to select the picture you want to use as the background. After confirming, Choose how you want to present it.
The last thing is to set the brightness of the background image. I suggest a brighter background at 10% transparency, too bright will affect the reading of the code.
I hope this article is helpful to you~~ If you are interested in software testing, interface testing, automated testing, performance testing, and interview experience exchanges, you can chat with me privately or pay attention to the public account "Testing" software test". Receive the latest interview materials from major software testing companies and learning materials on Python automation, interfaces, and framework building for free! Technical experts answer questions and communicate with peers.
Articles are uploaded by users and are for non-commercial browsing only. Posted by: Lomu, please indicate the source: https://www.daogebangong.com/en/articles/detail/Dry%20technical%20article%20PyCharm%20version%20control%20and%20practical%20tips.html
评论列表(196条)
测试