博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git 常用命令
阅读量:4043 次
发布时间:2019-05-24

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

查看是否存在文件需要上传

git status
git add .
git commit -m ''
创建远程仓库
git remote add origin 116.255.146.153:ruby_cd/work_daily_project.git
更新
git fetch 116.255.146.153:ruby_cd/work_daily_project.git master
合并代码
git merge origin/master
提交
git push origin master

==========================================================

初始化

创建版本库

git 基于文件夹(工作树)进行版本控制,在一个文件夹中创建 git版本库:

$ cd project/  $ git init   Initialized empty Git repository in .git/

输出信息:在当前文件夹的 .git/ 目录下创建版本库

将文件提交到 git索引:

git add file1 file2 file3 ……

更方便的作法是将当前文件夹中的所有文件全部加入到索引中

git add .
  • 可以在 .gitignore 文件中设置排除的文件(通常把临时文件排除)
[注意] 注意
git 只负责管理被索引的文件

此时,文件还没有被提交到版本库。向版本库提交第一个版本:

git commitgit commit -m "备注"

调用系统默认编辑器编辑备注内容

版本库状态

使用 git status 命令查看版本库状态。先创建一个演示版本库:

mkdir sandbox                 #新建一个文件夹cd sandbox/                   #进入该文件夹git init                      #初始化版本库touch a b                     #新建 a b 两个文件git add .                     #将这两个文件提交到索引git commit -m "创建git版本库"  #将第一个版本提交到版本库

这时使用 git status 查看版本库状态:

# On branch masternothing to commit (working directory clean)

对文件进行一些操作:

vi a      #编辑 arm b      #删除 btouch c   #新建 c

再用 git status 查看:

# On branch master          #在 master 分支上# Changes to be committed:  #已提交到索引,等待提交到版本库(其实本例中没有这一段)#   (use "git reset HEAD 
..." to unstage)## new file: e # modified: f ## Changed but not updated: #改动未提交到索引# (use "git add/rm
..." to update what will be committed)## modified: a# deleted: b## Untracked files: #文件未提交到索引# (use "git add
..." to include in what will be committed)## cno changes added to commit (use "git add" and/or "git commit -a")
[注意] 注意
如果只是想删除该文件夹中的版本库,只要删除 .git/ 目录即可
rm -rf .git

配置

git 初始化后,会在.git/目录下创建一个版本库,其中.git/config为配置文件。

用户信息

为当前版本库添加用户信息[]

[user]    name = kardinal    email = 2999am@gmail.com

也使用全局用户信息,在~/.gitconfig中写入上述内容,或者使用命令:

git config --global user.name "kardinal"git config --global user.email 2999am@gmail.com

语法高亮

~/.gitconfig文件中添加如下语句,使用容易阅读的彩色来输出信息:

[color]    branch = auto    diff = auto    status = auto

或者自己定义:

branch.current          # color of the current branchbranch.local            # color of a local branchbranch.plain            # color of other branchesbranch.remote           # color of a remote branchdiff                    # when to color diff outputdiff.commit             # color of commit headersdiff.frag               # color of hunk headersdiff.meta               # color of metainformationdiff.new                # color of added linesdiff.old                # color of removed linesdiff.plain              # color of context textdiff.whitespace         # color of dubious whitespacestatus                  # when to color output of git-statusstatus.added            # color of added, but not yet committed, filesstatus.changed          # color of changed, but not yet added in the index, filesstatus.header           # color of header textstatus.untracked        # color of files not currently being trackedstatus.updated          # color of updated, but not yet committed, files

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

你可能感兴趣的文章
Oracle Database 12c第2版(12.2)中的只读分区和子分区
查看>>
12.2: ORA-28040 Followed by ORA-1017 When Client is Under Version 12
查看>>
ORA-01031 TOAD 连接到12c数据库
查看>>
Docker-利用Dockerfile来搭建tomcat服务
查看>>
Docker跨服务器迁移
查看>>
VMware安装centos虚拟机 通过NAT与主机互通并能上网
查看>>
expdp/impdp 数据库迁移详细过程
查看>>
oracle 误删除表的几种恢复方法
查看>>
hadoop、hbase、hive、spark分布式系统架构详细搭建过程
查看>>
Hadoop与Hbase各版本对应关系
查看>>
impdp时ORA-39126: Worker unexpected fatal error in KUPW$WORKER.PUT_DDLS [TABLE_STATISTICS]
查看>>
OracleMTSRecoveryService 启动失败
查看>>
oracle job如何定时执行带参数的存储过程
查看>>
oracle12c存在pdb情况下的data guard 详细搭建
查看>>
oracle 查询自动补全日期以及相应的数据
查看>>
Centos7.4 zabbix3.4.8源码安装详细过程
查看>>
python 自动抓取网页新闻以及图片并存储到数据库中
查看>>
python监控系统(flask+python+html)
查看>>
oracle从备份集中恢复归档日志方法
查看>>
Oracle跨版本与跨平台执行传输表空间(XTTS)
查看>>