Git详细使用流程

Git详细使用流程

文章目录


初始化git仓库

git init

执行命令后文件夹下将会在执行命令路径下生成.git隐藏文件
上传该路径下的所有内容到暂存区

git add .

通常项目中都有read.me,创建read.me文件
将read.me添加到git仓的暂存区

git add read.me

查看代码改动

git status

使用git status后,命令行显示信息如下

On branch master

No commits yet

Changes to be committed:
(use "git rm --cached <file>..." to unstage)

        new file:   read.me

提交代码

git commit -m "备注信息"

提交代码后若提示如下

*** 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: empty ident name (for <left@left.localdomain>) not allowed

需要知道提交代码的人是谁,输入用户名以及用户邮箱即可,–global为全局设定

git config --global user.name "jayZhang"
git config --global user.email "***@*"

注册完后重新提交代码

git commit -m "备注信息"

查看提交信息

git log

显示的记录信息

commit a807111a632c1fb175d5d6685d9e38560f04715c (HEAD -> master, origin/master)
Author: Left23333 <49427269+Left23333@users.noreply.github.com>
Date:   Sat Apr 11 17:37:29 2020 +0800

    2020.4

若修改了代码,查看哪些文件出现了改动

git status

查看该文件修改的具体内容

git diff main.c

重置

git reset

查看具体某一条的提交信息

git show a807111a632c1fb175d5d6685d9e38560f04715c

回退某一次提交

git revert a807111a632c1fb175d5d6685d9e38560f04715c

设置全局编辑器使用vim

git config --global core.editor vim

克隆托管平台的代码

git clone https://仓库域名地址

要push的url

git remote add origin https://github.com/your_name/your_project_name

把远程仓库和本地同步,消除差异

git pull origin master --allow-unrelated-histories

push到远端托管平台

git push -u origin master

已经克隆过远端代码,需要更新远端代码到本地时,会比较远端与本地代码区别,选择性下载

git pull

博客园地址

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

left23333

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值