博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git clone->git commit->git push流程介绍
阅读量:4148 次
发布时间:2019-05-25

本文共 2762 字,大约阅读时间需要 9 分钟。

首先到github上面创建一个仓(或者下载其他人创建的也行)。

github新增仓库地址:
新增仓库默认为空的,复制仓库链接后执行git clone [url]下载到本地
在这里插入图片描述

[root@CSDN /home/Sudley/github]#git clone https://github.com/Sudley/git_learning.gitCloning into 'git_learning'...warning: You appear to have cloned an empty repository.[root@CSDN /home/Sudley/github]#lsgit_learning[root@CSDN /home/Sudley/github]#cd git_learning/[root@CSDN /home/Sudley/github/git_learning]#ls[root@CSDN /home/Sudley/github/git_learning]#

将github仓库clone到本地,A表示仓库节点

在这里插入图片描述
本地仓库新增bs.html文件

[root@CSDN /home/Sudley/github/git_learning]#vi bs.html[root@CSDN /home/Sudley/github/git_learning]#git status  #查看仓库状态,可以看到新增文件是未跟踪状态# On branch master## Initial commit## Untracked files:#   (use "git add 
..." to include in what will be committed)## bs.htmlnothing added to commit but untracked files present (use "git add" to track)[root@CSDN /home/Sudley/github/git_learning]#git add bs.html[root@CSDN /home/Sudley/github/git_learning]#git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached
..." to unstage) #若不想提交此新文件可以使用git rm --cached bs.html移除上面add操作的效果## new file: bs.html#[root@CSDN /home/Sudley/github/git_learning]#git commit -m "add bs.html"*** Please tell me who you are.Run git config --global user.email "you@example.com" git config --global user.name "Your Name"#to set your account's default identity.Omit --global to set the identity only in this repository.fatal: unable to auto-detect email address (got 'root@bogon.(none)')[root@CSDN /home/Sudley/github/git_learning]#git config --global user.name ******[root@CSDN /home/Sudley/github/git_learning]#git config --global user.email ******@**.com[root@CSDN /home/Sudley/github/git_learning]#git commit -m "add bs.html"[master (root-commit) 67ffb78] add bs.html 1 file changed, 30 insertions(+) create mode 100644 bs.html[root@CSDN /home/Sudley/github/git_learning]#git status# On branch main# Your branch is ahead of 'origin/main' by 1 commit. #提示本地分支比远程分支多一个commit# (use "git push" to publish your local commits)#nothing to commit, working directory clean[root@CSDN /home/Sudley/github/git_learning]#

此时远程仓和本地仓的节点状态如下,本地的比远程仓多一个节点

在这里插入图片描述
git push将本地仓修改推送到远程仓

[root@CSDN /home/Sudley/github/git_learning]#git pushCounting objects: 4, done.Compressing objects: 100% (3/3), done.Writing objects: 100% (3/3), 757 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)To https://github.com/Sudley/git_learning.git   9df625b..cd78fde  main -> main[root@CSDN /home/Sudley/github/git_learning]#git status# On branch mainnothing to commit, working directory clean[root@CSDN /home/Sudley/github/git_learning]#

在这里插入图片描述

此时查看github上面发现bs.html已添加成功
在这里插入图片描述

Tips:新增文件时需要先git add后再commit,如果是修改原文件且一次性提交所有修改则可以使用git commit -am命令替代git add xx和git commit -m。

转载地址:http://cyiti.baihongyu.com/

你可能感兴趣的文章
初始化VUE项目报错
查看>>
vue项目使用安装sass
查看>>
HTTP和HttpServletRequest 要点
查看>>
在osg场景中使用GLSL语言——一个例子
查看>>
laravel 修改api返回默认的异常处理
查看>>
laravel事务
查看>>
【JavaScript 教程】浏览器—History 对象
查看>>
这才是学习Vite2的正确姿势!
查看>>
7 个适用于所有前端开发人员的很棒API,你需要了解一下
查看>>
25个构建Web项目的HTML建议,你需要了解一下!
查看>>
【web素材】02-10款大气的购物商城网站模板
查看>>
6种方式实现JavaScript数组扁平化(flat)方法的总结
查看>>
49个在工作中常用且容易遗忘的CSS样式清单整理
查看>>
20种在学习编程的同时也可以在线赚钱的方法
查看>>
隐藏搜索框:CSS 动画正反向序列
查看>>
127个超级实用的JavaScript 代码片段,你千万要收藏好(上)
查看>>
【视频教程】Javascript ES6 教程27—ES6 构建一个Promise
查看>>
【5分钟代码练习】01—导航栏鼠标悬停效果的实现
查看>>
127个超级实用的JavaScript 代码片段,你千万要收藏好(中)
查看>>
127个超级实用的JavaScript 代码片段,你千万要收藏好(下)
查看>>