git 拉取同步步骤

一、 同步几种情况:

1、创建一个新仓库
git clone git@****/test.git(或https://开头的远程url)
cd test  //进入本地项目目录
touch README.md //新建介绍文档
git add README.md //添加到git
git commit -m "add README" //本地提交
git push -u origin master //服务器提交
2、推送现有文件夹
cd existing_folder //进入本地项目目录
git init //初始化
git remote add origin git@***/test.git //与服务器建立连接,要求服务器上是一个空的项目,只有项目名
git add . //将当前目录下文件添加到git
git commit -m "Initial commit" //本地提交
git push -u origin master //将本地分支origin 提交到服务器master分支
3、推送现有的 Git 仓库
cd existing_repo 
git remote rename origin old-origin //修改分支名称
git remote add origin git@***/test.git //建立连接
git push -u origin --all //提交本地所有分支到服务器
git push -u origin --tags //提交本地带标签的分支到服务器

 

二、若干命令

git status     查看未提交本地以及本地未提交服务器的文件

git rm --cached [文件名]   在git中逻辑删除,本地存在,只是git不跟踪,记得git commit 提交一下

git rm -f [文件名]     强制删除,本地还有git都删除

git reset HEAD~1 回退上一步,不能回来,注意小波浪线是esc下面的键

git revert HEAD 撤销更改,还能回来,有新节点记录

git checkout 【newImage】  切换到新分支

 

三、报错

git clone 报错,原因 服务器未开启ssh服务,22端口未开放

ssh: connect to host gitlab.app.guomeng.name port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

 

git push 报错,原因服务器限制了上传文件的大小,修改下服务的配置,比如私搭的服务器gitlab的配置

fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
Everything up-to-date

 

git push报错,方案删除项目下的.git文件夹,重新init来过

fatal: unable to access 'https://***/test.git/': Port number ended with 'y'

 

四、推荐个学习git的网站,图形化命令,形象记忆

git学习

 

posted @ 2020-07-09 14:03  风起时的悟  阅读(1970)  评论(0编辑  收藏  举报