下载代码
创建本地仓库目录
mkdir moduocode
进入本地仓库目录
cd moduocode
初始化版本仓库
git init
从GitHub克隆一个版本库,在项目右侧显示:复制url
git clone https://github.com/chenshuo/muduo.git
获取历史版本代码
方案一: git checkout v3.0
方案二: git checkout
git tag
本地所有修改的,没有的提交的,都返回到原来的状态
git checkout.
切换到tag历史记录会处在分离头指针状态,这个是的修改是很危险的,在切换回主线时如果没有合并,之前的修改提交基本都会丢失,如果需要修改可以尝试git checkout -b branch tag创建一个基于指定tag的分支,例如:gitcheckout -b tset v0.1.0 这个时候就会在分支上进行开发,之后可以切换到主线合并
获取原始地址(远程仓库的 URL)
打开命令行或终端,导航到克隆下来的 Git 仓库的根目录,然后运行以下命令:
[root@localhost tcpkill]# git remote -v
origin https://github.com/chartbeat/tcpkill.git (fetch)
origin https://github.com/chartbeat/tcpkill.git (push)
直接打开 Git 仓库目录下的 .git/config
文件来查看原始地址
版本管理
1)应用场景
目前修改了一些代码,提交到SVN上,然后发现并不合理,然后手动删除代码,重新提交
2)误区
导致某些代码并没有清除,如果当前没有任何人提交代码,可以还原版本,如果已经有人提交了代码,必须通过SVN提交的代码进行历史版本的对比,而不是根据可能就几处修改了代码。
更新代码
1)应用场景
发布版本的时候,务必确保已经由他人编译的库是最新的
The remote end hung up unexpectedly
场景
$ git clone https://github.com/shimat/opencvsharp.git
Cloning into 'opencvsharp'...
remote: Enumerating objects: 135, done.
remote: Counting objects: 100% (135/135), done.
remote: Compressing objects: 100% (90/90), done.
error: RPC failed; curl 56 SSL read: error:00000000:lib(0):func(0):reason(0), errno 10054
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
解决方案
公司网络慢因此设置git配置参数,否则因此超时退出
$ git config --global http.lowSpeedLimit 0
$ git config --global http.lowSpeedTime 999999
$ git config --global http.postBuffer 5242880
fetch-pack: unexpected disconnect while reading sideband packet
采用git pull更新UE5.1代码报错
解决
网速不给力,找个少人上网的时间,多次执行
libcdio: Existing folder found. Checking for updates...
fatal: unable to access 'https://github.com/ShiftMediaProject/libcdio.git/': Failed to connect to github.com port 443: Timed out