分布式版本控制系统Git-----4.Git 常用命令整理

1. git init  

初始化 git 目录  

 

2. git add  

添加文件  

  

    git add fileName       #添加指定文件  

    git add -i             #手工选择要添加的文件  

    git add -A             #所有的更改操作--新建,更改,删除;  

    git add .              #只包括 新建 ,修改操作;无删除;  

    git add -u             #只包括修改,删除操作,无新建;  

    git add -p             #提交确认  

  

 

3. git status  

查看状态 

 

4. git commit -m 'xxxx'  

提交  

 

5. git remote add xx git@server:user/project.git  

指定远程库  

   git remote -v                             #查看远程仓库  

    git remote add [name] [url]               #添加远程仓库  

   git remote rm [name]                      #删除远程仓库  

   git remote set-url --push[name][newUrl]   #修改远程仓  

 

 

6. git push origin master  

更新到远程库 git push [remoteName] [localBranchName]  

 

 

7. git pull  

从远程库获取 git pull [remoteName] [localBranchName]  

等于下面两条命令  

    git fetch  

    git merge  

 

  

8. git config --global user.name "name"  

   git config --global user.email "user@example.com"  

配置用户信息  

  

 

9. .gitignore  

创建此文本文件来忽略相关文件  

 

10. clone  

   用法1: git clone          <repository> <directory>  

   用法2: git clone --bare   <repository> <directory.git>  

   用法3: git clone --mirror <repository> <directory.git>  

这三种用法的区别如下:  

==>用法1 <repository> 指向的版本库创建一个克隆到 <directory> 目录。目录 <directory> 相当于克隆版本库的工作区,文件都会检出,版本库位于工作区下的 .git 目录中。  

==>用法2和用法3创建的克隆版本库都不包含工作区,直接就是版本库的内容,这样的版本库称为祼版本库。一般约定俗成裸版本库的目录名以 .git 为后缀,所以上面示例中将克隆出来的裸版本库目录名写作 <directory.git>  

==>用法3区别于用法2之处在于用法3克隆出来的裸版本对上游版本库进行了注册,这样可以在裸版本库目录中使用 git fetch 命令和上游版本库进行持续同步。  

==>用法3只在 1.6.0 或更高版本的 git 中才提供。 

posted on 2016-11-28 22:34  有梦想的乌龟·  阅读(206)  评论(0编辑  收藏  举报

导航