git clone->git commit->git push流程介绍

首先到github上面创建一个仓(或者下载其他人创建的也行)。
github新增仓库地址:https://github.com/new
新增仓库默认为空的,复制仓库链接后执行git clone [url]下载到本地
在这里插入图片描述

[root@CSDN /home/Sudley/github]#git clone https://github.com/Sudley/git_learning.git
Cloning into 'git_learning'...
warning: You appear to have cloned an empty repository.
[root@CSDN /home/Sudley/github]#ls
git_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 <file>..." to include in what will be committed)
#
#       bs.html
nothing 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 <file>..." 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 push
Counting 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 main
nothing 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。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值