Git安装与基本操作
来源:互联网 发布:postgresql 数据加密 编辑:程序博客网 时间:2024/05/16 02:29
1、安装git
$ sudo apt-get udpate
$ sudo apt-get install git
$ sudo apt-get install git-doc git-svn git-email git-gui gitk
2、绑定用户
用于与GitHub建立联系,直接使用GitHub账户
$ git config --global user.name "stone927"
$ git config --global user.email "787724030@qq.com"
3、创建本地库
$ mkdir GitHome
$ cd GitHome
$ git init
4、添加新文件
$ git add hello.c
$ git commit -m "add hello.c"
(注意:更新文件同样需要这两步操作)
5、查看当前本地库状态
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: hello.c
no changes added to commit (use "git add" and/or "git commit -a")
6、比较当前文件与版本库的区别
$ git diff hello.c
diff --git a/hello.c b/hello.c
index 41dd832..50aa6ca 100644
--- a/hello.c
+++ b/hello.c
@@ -3,6 +3,6 @@
int
main(void)
{
- printf("Hello World!\n");
+ printf("Hello World1!\n");
return 0;
}
7、查看修改日志
$ git log
commit 10bb9d5f4fae072a119957e517c619010d918fa7
Author: stone <787724030@qq.com>
Date: Wed Nov 22 17:12:00 2017 +0800
in hello.c
commit b3f326437969b29f43b82c47d0f937a7c4a2bb3c
Author: stone <787724030@qq.com>
Date: Wed Nov 22 17:05:46 2017 +0800
add a file
8、回退版本
$ git reset --hard HEAD^
(说明:有几个'^'表示回退多少个版本,这里表示回退大上一版本)
9、查看远程分支
$ git branch -a
10、查看本地分支
$ git branch
11、创建分支
$ git branch -b myBranch
12、切换到某分支
$ git checkout myBranch
13、删除本地分支
$ git branch -d myBranch- Git安装与基本操作
- Git-01_安装与基本操作
- git Bash 安装&配置与基本操作
- Git安装与基本操作总结
- git安装教程与基本操作
- GIT安装与操作
- Git与TortoiseGit基本操作
- Git与TortoiseGit基本操作
- Git 命令与基本操作
- Git与TortoiseGit基本操作
- Git与TortoiseGit基本操作
- Git与TortoiseGit基本操作
- Git与github基本操作
- Git与TortoiseGit基本操作
- Git与TortoiseGit基本操作
- Git与TortoiseGit基本操作
- Git与TortoiseGit基本操作
- Git与github基本操作
- package.json 文件
- ubuntu 安装NVIDIA 显卡后分辨率改变成640*480解决办法
- 2017 ICPC 西安/青岛 站
- openCV人脸识别
- C++函数返回值
- Git安装与基本操作
- es6解构赋值(2)
- C语言中如何将二维数组作为函数的参数传递
- python+selenium几种常见的定位方法(整合)
- k8s命令总结
- java在Linux与win下面路径分割符
- 格式化php代码
- curl get
- 第十课 内容编辑器