关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

Git操作手册

发布时间:2023-06-26 19:00:17

上传项目到GitHub

1.GitHub新建Repository

2.下载Git,找到所要上传的项目文件夹,右键GitBashHere

3.创建本地Git仓库

git init

   

4.将代码文件添加到本地Git仓库中

git add .

   

5.提交代码到本地仓库

git commit -m "first init"

   

6.将本地仓库关联到GitHub

git remote add origin https://github.com/zlxzlxzlx/Test.git

   

7.把本地库推送到远程库

git push -u origin master

   

如果生成GitHub的repository的时候,选择了README文件

则需要

git pull --rebase origin master

   

合并提交

8.配置全局用户名密码

1. git config --global user.name "zhazhahui" 2. git config --global user.email "zhazhahui@qq.com"

   

9.如果配置的远程github库是https形式的,每次提交代码和更新的代码都需要输入用户名密码所以,接下来采用ssh方式提交代码

需要先在本地生成ssh秘钥

ssh-keygen -t rsa -C "zhazhahui@qq.com"

   

一路next,千万不要输入密码,不然很麻烦

1. cd ~/.ssh 2. cat id_rsa.pub

   

复制秘钥,代开Github,在setting>SSHandGPGkeys中新增New SSH Key,把秘钥复制粘贴进去

10.提交代码

git push -u origin master

   

11.查看git仓库状态

git status

   

11.更新代码

git pull origin master

   

12.切换远端提交更新路径,由hhtp方式切换为ssh方式

 

git remote set-url origin git@github.com:zhazhahui/iotplant.git

   

13.克隆已存在项目到本地,并提交

git clone git@github.com:xxxxx/iotxxview.git

   

 然后进入项目所在目录

1. git add . 2. git commit -m 'ceshi' 3. git push -u origin master

   

14.Git从服务器拉取覆盖本地代码

1. git fetch --all 2. 3. git reset --hard origin/master 4. 5. -- git reset --hard origin/拉取的分支 6. 7. git pull

   

15.Git强制提交覆盖服务器的代码

git push origin master --force

   

16.Git下载项目失败(项目太大)

error: RPC failed; curl 18 transfer closed with outstanding read data remaining fatal: the remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed

     

git config http.postBuffer 524288000 --增大缓存为500M

     

git config http.sslVerify "false" git config --global http.sslVerify "false"

   



/template/Home/leiyu/PC/Static