git 使用

本文介绍了如何配置Git个人信息,初始化Git仓库,以及常用的Git命令,包括添加文件、提交更改、查看状态和查询历史记录等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

git

首先是down 一个了,这里就省略了(以下为linux 下的使用, 其他系统会有不同)

配置git

    1.通过命令     git config --global user.name "yourname"    

                    git config --global user.email "your email"

    2.或者通过修改配置

                   进入主目录 cd ~/     然后vim .gitconfig    打开配置文件, 然后 添加 [user]   name = "your name"   email = "your email"  即可


初始化:

    1. 使用 git init  这时候初始化仓库,然后可以在本目录下创建自己的工程了, 比如创建一个文件 touch heh.c  , 这时候可以将你的hehe.c 加入到仓库中,使用 git add hehe.c

git commit -m "add the hehe to  the git"

    2. 可以通过git clone [远程或本地仓库]   将其他仓库clone 到本地一份, 这个也主要是用于初始化仓库


常用命令 

git add   hello.c  告诉git  hello.c 改动了, 跟踪他

git commit -m "改动描述"    当***改动了, add只是跟踪, 并没有加入到库中,现在将改动提交到库中 

git status  检查当前状态 如果改动了本地文件, 它会显示让你去 add这个改动, 如果add了一个改动, 他会提示去将这个改动添加到仓库

比如说: git add hello.c   会显示:

$ git add hello.c
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#	modified:   hello.c
继续 git status 会有 

# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   hello.c
#

查询历史

git log

可以查询历史 


。。。时间原因, 会有更新



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值