网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Git有什么常用的命令

本篇内容主要讲解“Git有什么常用的命令”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Git有什么常用的命令”吧!

创新互联公司一直通过网站建设和网站营销帮助企业获得更多客户资源。 以"深度挖掘,量身打造,注重实效"的一站式服务,以成都网站建设、做网站、移动互联产品、全网营销推广服务为核心业务。10余年网站制作的经验,使用新网站建设技术,全新开发出的标准网站,不但价格便宜而且实用、灵活,特别适合中小公司网站制作。网站管理系统简单易用,维护方便,您可以完全操作网站资料,是中小公司快速网站建设的选择。

1、git clone

功能:克隆git仓。

格式:git clone url

用法:

## clone rockpi代码,下载完成后,代码存储在rockchip-bsp文件夹git clone --recursive https://github.com/radxa/rockchip-bsp.git## clone rockpi代码,下载完成后,代码存储在rockpi文件夹git clone --recursive https://github.com/radxa/rockchip-bsp.git rockpi

clone完成后,已经存在git仓。

如果本地代码没有git仓,可使用git init命令初始化空的git仓。

2、git init

功能:初始化本地仓,命令执行完后生成.git文件夹。用于新建本地git仓,进行代码管理。

格式:git init

用法:

root@ubuntu:/home/run/code/libdrm-2.4.89# git initInitialized empty Git repository in /home/run/code/libdrm-2.4.89/.git/
3、git status

功能:检查当前文件状态。

格式:git status

用法:

root@ubuntu:/home/run/code/libdrm-2.4.89# git statusOn branch masterNo commits yetUntracked files:  (use "git add ..." to include in what will be committed)        Makefile.am        Makefile.in        Makefile.sources        README        aclocal.m4        amdgpu/        ...

注:由于是本地新建git仓,此时文件属于Untracked状态。

4、git add

功能:跟踪文件。

格式:git add

用法:

root@ubuntu:/home/run/code/libdrm-2.4.89# git add .root@ubuntu:/home/run/code/libdrm-2.4.89# git statusOn branch masterNo commits yetChanges to be committed:  (use "git rm --cached ..." to unstage)        new file:   Makefile.am        new file:   Makefile.in        new file:   Makefile.sources        new file:   README        new file:   aclocal.m4        new file:   amdgpu/Makefile.am

注:

1)git add filename:跟踪名为filename的文件。

2)git add -u:跟踪被修改或删除文件,不包括新增文件。

3)git add .:跟踪所有变化,等同git add -A

## 1.删除git仓中的README,新增加readme.txtroot@ubuntu:/home/run/code/test/libdrm-2.4.89# rm READMEroot@ubuntu:/home/run/code/test/libdrm-2.4.89# touch readme.txtroot@ubuntu:/home/run/code/test/libdrm-2.4.89# git statusOn branch masterChanges not staged for commit:  (use "git add/rm ..." to update what will be committed)  (use "git checkout -- ..." to discard changes in working directory)        deleted:    READMEUntracked files:  (use "git add ..." to include in what will be committed)        readme.txtno changes added to commit (use "git add" and/or "git commit -a")## 2. git add . :跟踪所有变化,和 git add -A 相同root@ubuntu:/home/run/code/test/libdrm-2.4.89# git add .root@ubuntu:/home/run/code/test/libdrm-2.4.89# git statusOn branch masterChanges to be committed:  (use "git reset HEAD ..." to unstage)        deleted:    README        new file:   readme.txt## 3. 回退到步骤1root@ubuntu:/home/run/code/test/libdrm-2.4.89# git reset HEAD READMEUnstaged changes after reset:D       READMEroot@ubuntu:/home/run/code/test/libdrm-2.4.89# git reset HEAD readme.txtUnstaged changes after reset:D       READMEroot@ubuntu:/home/run/code/test/libdrm-2.4.89# git statusOn branch masterChanges not staged for commit:  (use "git add/rm ..." to update what will be committed)  (use "git checkout -- ..." to discard changes in working directory)        deleted:    READMEUntracked files:  (use "git add ..." to include in what will be committed)        readme.txtno changes added to commit (use "git add" and/or "git commit -a")## 4. git add -uroot@ubuntu:/home/run/code/test/libdrm-2.4.89# git add -uroot@ubuntu:/home/run/code/test/libdrm-2.4.89# git statusOn branch masterChanges to be committed:  (use "git reset HEAD ..." to unstage)        deleted:    READMEUntracked files:  (use "git add ..." to include in what will be committed)        readme.txt    ## 新增文件没有被跟踪
5、git commit

功能:提交更新。

格式:git commit

用法:

root@ubuntu:/home/run/code/libdrm-2.4.89# git commit -m "Init code"[master (root-commit) bfa9cc1] Init code 337 files changed, 156347 insertions(+) create mode 100644 Makefile.am create mode 100644 Makefile.in create mode 100644 Makefile.sources create mode 100644 README create mode 100644 aclocal.m4 create mode 100644 amdgpu/Makefile.am

注:

1)git commit:启动文本编辑器,输入提交说明。文本编辑器使用git config指定,可参考前一篇文章。

2)git commit -m “...”:在-m后输入提交信息,直接提交。

3)git commit --amend:对上次提交的信息进行修改。

例:

新建本地libdrm-2.4.89 代码git仓方法如下:

root@ubuntu:/home/run/code/libdrm-2.4.89# git initroot@ubuntu:/home/run/code/libdrm-2.4.89# git add .root@ubuntu:/home/run/code/libdrm-2.4.89# git commit -m "Init code"
6、.gitignore

功能:忽略文件

git仓目录下编辑.gitignore文件,忽略不需要纳入git仓管理的文件,例:编译后生成的.o等文件。

## 1.新建1.o测试文件,git status查看文件状态root@ubuntu:/home/run/code/libdrm-2.4.89# touch 1.oroot@ubuntu:/home/run/code/libdrm-2.4.89# git statusOn branch masterChanges to be committed:  (use "git reset HEAD ..." to unstage)        deleted:    README        new file:   readme.txtUntracked files:  (use "git add ..." to include in what will be committed)        1.o## 2.编辑.gitignoreroot@ubuntu:/home/run/code/libdrm-2.4.89# vi .gitignoreroot@ubuntu:/home/run/code/test/libdrm-2.4.89# cat .gitignore*.o## 3.查看文件状态时,没有1.o文件root@ubuntu:/home/run/code/libdrm-2.4.89# git statusOn branch masterChanges to be committed:  (use "git reset HEAD ..." to unstage)        deleted:    README        new file:   readme.txtUntracked files:  (use "git add ..." to include in what will be committed)        .gitignore

到此,相信大家对“Git有什么常用的命令”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!


新闻名称:Git有什么常用的命令
分享地址:http://bjjierui.cn/article/pgdhjp.html

其他资讯