git安装
apt-get install git
安装
pip insatll git
出现问题:
(base) [root@GS04 yaolinxia]# pip install git
Collecting git
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/git/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/git/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/git/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/git/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/git/
Could not fetch URL https://pypi.org/simple/git/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/git/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))) - skipping
ERROR: Could not find a version that satisfies the requirement git (from versions: none)
ERROR: No matching distribution found for git
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))) - skipping
使用sudo yum install git
出现问题
[root@GS04 pycorrector]# git pull
fatal: unable to access 'https://github.com/yaolinxia/pycorrector.git/': Peer's Certificate issuer is not recognized.
解决:https://blog.csdn.net/fenglailea/article/details/50041219
git config --global http.sslVerify false
继续有问题
(base) [root@GS04 yaolinxia]# git clone https://github.com/yaolinxia/pycorrector.git
正克隆到 'pycorrector'...
fatal: repository 'https://github.com/yaolinxia/pycorrector.git/' not found
配置用户名、邮箱
git config --global user.name "yaolinxia"
git config --global user.email "18860976931@163.com"
使用git-clone
-
克隆一个新项目
-
拉取远程最新的更新
需要进入该项目文件夹下使用git pull
root@20a49529b74e:/usr/local/src# ll 总用量 0 drwxr-xr-x. 1 root root 36 6月 2 13:30 ./ drwxr-xr-x. 1 root root 40 7月 10 2018 ../ drwxr-xr-x 10 root root 268 6月 2 13:30 ocr_Correction/ root@20a49529b74e:/usr/local/src# git pull fatal: 不是一个 git 仓库(或者任何父目录):.git root@20a49529b74e:/usr/local/src# cd ocr_Correction/ root@20a49529b74e:/usr/local/src/ocr_Correction# git pull remote: Enumerating objects: 7, done. remote: Counting objects: 100% (7/7), done. remote: Compressing objects: 100% (1/1), done. remote: Total 4 (delta 3), reused 4 (delta 3), pack-reused 0 展开对象中: 100% (4/4), 完成. 来自 https://github.com/ocrcorrection/ocr_Correction b3b682d..a5ba2d7 master -> origin/master 更新 b3b682d..a5ba2d7 Fast-forward utils/Ocr_titleClass.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) root@20a49529b74e:/usr/local/src/ocr_Correction#
- 查看远程库信息,使用
git remote -v
; - 本地新建的分支如果不推送到远程,对其他人就是不可见的;
- 从本地推送分支,使用
git push origin branch-name
,如果推送失败,先用git pull
抓取远程的新提交; - 在本地创建和远程分支对应的分支,使用
git checkout -b branch-name origin/branch-name
,本地和远程分支的名称最好一致; - 建立本地分支和远程分支的关联,使用
git branch --set-upstream branch-name origin/branch-name
; - 从远程抓取分支,使用
git pull
,如果有冲突,要先处理冲突。
利用Git从本地上传到GitHub
第一步: 进入要所要上传文件的目录输入命令 “git init”
第二步: 创建一个本地仓库,使用命令 “git remote add origin git@github.com:yourName/yourRepo.git”
youname是你的GitHub的用户名,yourRepo是你要上传到GitHub的仓库
第三步: 比如你要添加一个文件xxx到本地仓库,使用命令 “git add xxx”,可以使用“git add .”自动判断添加哪些文件
然后把这个添加提交到本地的仓库,使用命令 ”git commit -m ”说明这次的提交“ “
最后把本地仓库提交到远程的GitHub仓库,使用命令 ”git push origin master“
提交本地更新
git config --global user.email "18860976931@163.com"
git config --global user.name "yaolinxia"
git commit -a
git pull
远程拉项目到本地
git clone 复制项目地址
删除本地仓库
rm -rf .git #删除
问题
文件夹中存在大文件,比如数据等
- 解决
git rm --cached giant_file
# Stage our giant file for removal, but leave it on disk
git commit --amend -CHEAD
# Amend the previous commit with your change
# Simply making a new commit won't work, as you need
# to remove the file from the unpushed history as well
git push
# Push our rewritten, smaller commit