1. 程式人生 > 實用技巧 >PyCharm外掛:git版本控制

PyCharm外掛:git版本控制

2020年11月13日

環境:

win10

PyCharm 2020.1.3 (Professional Edition)

準備工作:

1.下載git:

git版本:

git --version
git version 2.29.2.windows.2

下載:https://git-scm.com/

2.註冊GitHub賬號:https://github.com/


開啟cmd:檢視git的配置

git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
core.editor="C:\\Program Files (x86)\\Notepad++\\notepad++.exe" -multiInst -notabbar -nosession -noPlugin
pull.rebase=false
credential.helper=manager-core
credential.https://dev.azure.com.usehttppath=true

需要設定使用者和郵件地址用於標記版本:

git config --global user.name xx
git config --global user.email [email protected]

===

開啟pycharm設定,在版本控制git選項中會自動檢查

===

在GitHub中新增賬號,用來上傳儲存

上傳程式碼

這時會把當前project的所有檔案預設選中,我們只需要選擇需要的檔案上傳即可:

等待上傳結束

網路問題,連不上,好吧,我先跳過這一步

===

雖然沒有上傳成功,但是git已經幫我們把程式碼加入了Git,一般來說,一個檔案需要先【add】進Git,然後【commit file】儲存當前版本,【get】恢復到指定版本

之後建立新的檔案時,pycharm也會自動詢問是否加入git,注意未加入git前是紅色的

也可以在檔案右鍵add

現在算便寫點什麼,再commmit file,在上圖中Add的上面

之後彈出對話方塊,commit即可

再寫點什麼,再次commit file

注意:我們現在有所做的版本控制都是在本地

也可以在pycharm自動加入到toolbar裡的快捷按鈕來做

看一下歷史記錄,選擇v1,右鍵get,即可返回之前的版本


git還有很多適用功能沒有介紹,比如branch,以後用到再加吧