github上创建远程仓库(不创建readme)
提交:
本地项目文件夹:
gitbash here
git init
git status
git add .
git commit -m "first commit"
提交不上需要关联
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git remote add origin https://github.com/xxx/xx.git
git push -u origin master
本地更新到git:
git status
git add *
git commit -m "update"
git pull
git push origin master
下载:
创建根文件夹(下载下来是一个文件名为项目的文件,所以根目录可以直接设置为D:/ --> 直接磁盘根目录下右键->git bash here)
git clone git地址即可(ssh速度会快点)
git更新到本地:
//在本地新建一个temp分支,并将远程origin仓库的master分支代码下载到本地temp分支
git fetch origin master:tmp
//来比较本地代码与刚刚从远程下载下来的代码的区别
git diff tmp
//合并temp分支到本地的master分支
git merge tmp
//如果不想保留temp分支 可以用这步删除
git branch -d temp
push可能出现的问题:
1:HttpRequestException encountered :
到https://github.com/microsoft/Git-Credential-Manager-for-Windows下载Git-Credential-Manager-for-Windows(选release下的exe即可)
2:RPC failed;curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL,errno 10054
git上传文件有限制文件大小,当前上传的文件过大,那么在当前文件执行:git config http.postBuffer 524288000
执行完重新推送就好了
3:fatal: Updating an unborn branch with changes added to the index.
远程仓库有reademe本地没有,git pull --rebase origin master
所以一开始要求不创建readme
4:fatal: 'origin' does not appear to be a git repository
git remote add origin xx.git
将关联远程仓库为origin
git clone报错: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054,有文件太大导致的。
git config --global http.postBuffer 524288000
还不行,再来一句
git config --global http.sslVerify "false"
*********************************************** gitee ************************************************
远程仓库的搭建
gitee新建仓库,使用readme初始化
本地仓库的搭建
本地代码文件,右键gui here,创建new repository,然后rescan把unstaged changes中的内容stage changed到stage(暂存区)中
-- 可以理解成所有的操作基本是在本地仓库中进行的(.git)相当于add以便于后续的commit,文件较多需要等待
提交成功后,我们可以在Repository->Visualize All Branches History中看到我们提交的历史记录(这是提交到本地而不是提交到远程服务器)。至此,本地版本库就创建成功了。
本地仓库联系远程仓库
remote -> add new remote ,填写 名称和http (没用ssh)
push之前需要先 fetch然后merge再push
注意:如果不是clone出来的本地仓库,那么默认本地仓库和远程仓库是两个不同的仓库,无法merge
git pull origin master --allow-unrelated-histories