pycharm 使用git 一些列問題

使用的基礎(chǔ)命令

git config --global user.name "J**k-**"
git config --global user.email "lan***@163.com"
git config --global http.postbuffer 3194304000

# 查看系統(tǒng)config
git config --system --list
 
#查看當(dāng)前用戶(global)配置
git config --global  --list

#Create a new repository 創(chuàng)建一個新的存儲庫
git clone https://gitlab.com/qunzu1/xiangmu_1.git
cd xiangmu_1
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

現(xiàn)有文件夾
cd existing_folder
git init
git remote add origin https://gitlab.com/qunzu1/xiangmu_1.git
git add .
git commit -m "Initial commit"
git push -u origin master

現(xiàn)有的 Git 存儲庫
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/qunzu1/xiangmu_1.git
git push -u origin --all
git push -u origin --tags

在github上刪除某個文件:

因為在github上不能直接刪除某個文件,所以必須用git命令去刪除文件,在上傳的項目文件里打開git,我要刪除image文件,

如下圖:

輸入git pull origin master把github上的文件重新拉下來,如圖:

然后輸入命令dir 查看目錄下的文件,如下圖:

再輸入命令git rm -r --cached image刪除磁盤上的image文件,如下圖:

再輸入命令git commit -m '刪除了image' 提交添加說明,如下圖:

最后輸入git push -u origin master更新github倉庫,如下圖:

這時你的image文件就成功刪除,項目上添加了"刪除了image"的說明,如下圖:

1. 在pycharm 使用git

    1. 首先安裝git 軟件
    1. pycharm配置git


    1. 復(fù)制gitlib的url ,拉取數(shù)據(jù)(pull)



      image.png
  • 4 之后,add --> commit --> push
    之后更新版本pycharm2020版本后,發(fā)現(xiàn)提交流程有點變化
    首先創(chuàng)建相同的文件夾



之后的流程一樣啦。

2. git 提交代碼遇到的問題

1. 提交文件總量過大

報錯:
Failed with error: the remote end hung up unexpectedly the remote end hung up unexpectedly unable to rewind rpc post data - try increasing http.postBuffer RPC failed; curl 56 Recv failure: Connection was reset
解決方法:
此問題就是由于提交文件總量過大造成的。
在項目所在路徑下打開文件 .git --> config ,編輯config 文件添加

# 設(shè)置http緩存為1000M(大小可以根據(jù)需要自行更改)
[http]
postbuffer = 3194304000

如果是命令提交,則打開Git輸入如下兩行指令:

## 設(shè)置http緩存為1000M(大小可以根據(jù)需要自行更改)
git config --global http.postBuffer 3194304000
## 設(shè)置https緩存為1000M
git config --global https.postBuffer 3194304000

如果設(shè)置之后提交還是報錯的話,

git config --global http.version HTTP/1.1

可能是因為某幾個文件過大造成的;

這時就需要用到** git-lfs 具體用法見官網(wǎng) **https://git-lfs.github.com/

git lfs install
 
git lfs track "*.h5"
git lfs track "*.caffemodel"
 
git add .gitattributes

設(shè)置完后就可以按正常方式提交,問題解決.......

如果報錯連接錯誤,很有可能公司服務(wù)端設(shè)置單個文件大小的限制

3. Git分支操作命令

// 注:以下所有命令中的develop為分支名字

1. 查看分支

// 查看本地分支
git branch

// 查看所有分支(包括本地和遠(yuǎn)程分支)
git branch -a

2. 創(chuàng)建本地分支

// 2.1 遠(yuǎn)程不存在develop分支
git branch develop
// (創(chuàng)建并切換)
git checkout -b develop

// 2.1 遠(yuǎn)程存在develop分支
git branch develop origin/develop
// (創(chuàng)建并切換)
git checkout -b develop origin/develop

3. 切換分支

// 切換到develop分支
git checkout develop

4. 推送本地分支到遠(yuǎn)程

// 4.1 遠(yuǎn)程不存在develop分支(第二個develop分支是遠(yuǎn)程分支的名字)
git push origin develop:develop

// 4.2 遠(yuǎn)程存在develop分支,但和本地develop分支沒有關(guān)聯(lián)(前提是:已經(jīng)切換到develop下)
git push -u origin/develop

// 4.3 遠(yuǎn)程存在develop分支,并且和本地develop分支已關(guān)聯(lián)(前提是:已經(jīng)切換到develop下)
git push origin develop

5. 刪除分支

// 5.1 刪除本地分支
git branch -d develop

// 5.2 刪除遠(yuǎn)程分支
// 刪除遠(yuǎn)程develop分支(第二個命令表示:推送一個空的分支到遠(yuǎn)程develop分支)
git branch -r -d origin/develop
git push origin :develop

// 如果要刪除master分支,需要在gitserver上將master設(shè)置為默認(rèn)分支的選項取消(選擇其他分支作為默認(rèn)分支)
git branch -r -d origin/master
git push origin :master

6. 合并分支

// 將develop本地分支的內(nèi)容合并到本地master分支(需要先切換到master分支)
git merge develop
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容