惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
Hacker News: Ask HN
Hacker News: Ask HN
S
Securelist
Security Latest
Security Latest
S
Schneier on Security
T
Threat Research - Cisco Blogs
Latest news
Latest news
Cyberwarzone
Cyberwarzone
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
I
Intezer
T
The Exploit Database - CXSecurity.com
N
News and Events Feed by Topic
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
Blog — PlanetScale
Blog — PlanetScale
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CERT Recently Published Vulnerability Notes
The Hacker News
The Hacker News
月光博客
月光博客
WordPress大学
WordPress大学
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
量子位
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cisco Blogs
博客园 - 三生石上(FineUI控件)
Google DeepMind News
Google DeepMind News
Project Zero
Project Zero
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
L
LINUX DO - 最新话题
Schneier on Security
Schneier on Security
Engineering at Meta
Engineering at Meta
www.infosecurity-magazine.com
www.infosecurity-magazine.com
aimingoo的专栏
aimingoo的专栏
D
Docker
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
宝玉的分享
宝玉的分享
T
Troy Hunt's Blog
L
Lohrmann on Cybersecurity
T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
LangChain Blog

博客园 - fengyv

塑造职场影响力的五大法宝 怎样培养独挡一面的能力 数据结构 - 归并排序(merging sort) [分享]恼人的设计模式 设计师整理的系统开发流程-简洁又有重点 JavaScript中的String对象 python高效解析日志入库 如何让js不产生冲突,避免全局变量的泛滥,合理运用命名空间 HTML CSS——margin和padding的学习 三层浅析及示例分析 C语言的代码内存布局详解 超级立方体小记 如何和项目经理沟通产品的交付? CentOS配置smaba与Windows共享文件 Javascript实现简单的下拉二级菜单 从测试员到测试负责人 项目团队中4种组员类型的相应管理方式 在软件项目管理中如何把时间估算的靠近真实值? 性能优化——算法优化
Git使用总结
fengyv · 2014-06-16 · via 博客园 - fengyv

一、Git的特性

Speed 速度(git是用c语言写的。一般都是提交到本地)
Simple design
Strong support for non-linear development (thousands of parallel branches)(强有力的支持非线性开发) 
Fully distributed(分布式)
Able to handle large projects like the Linux kernel efficiently (speed and data size)

二、Git的架构原理

1.快照和索引而不是增量,svn是增量

2.几乎所有的操作都是本地的

3.Git文件的三个状态


Committed :文件安全的存储在你的本地. 
Modified :你修改了文件,但还未提交到你的仓库. 
Staged : 已经标记了一个已修改文件到下一个版本的快照

相应流程如下:
(1),工作区修改文件
(2),adding 快照到stage区域
(3),commit 提交到仓库

4.文件状态生命周期

三、安装Git及使用前的准备

1.安装,直接上官网下载安装

2.安装完成之后查看系统环境变量,设置身份

(1),了解系统环境变量
/etc/gitconfig
.gitconfig 

(2),设置身份
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

(3),设置编辑器(可选)
$ git config --global core.editor emacs

(4),设置你的比较工具(可选)
$ git config --global merge.tool vimdiff

(5),检查你的配置(可选)
$ git config --list

(6),帮助
$ git help <verb>
$ git <verb> --help

3.开发前需理解的四个区域

blessed (remote) repository 远程仓库
local repository 本地仓库
stage area 临时区
work area 工作区

四、Git相关命令

基本命令

1.初始化 

(1)init 进入工作区间文件夹,git init

(2)clone 从远程服务器调用git clone git://github.com/wsj/test.git

2.由工作区workspace加入到临时区staged,add命令

git add *.java
git add wsj.txt

3.由临时区staged提交到本地仓库local repository

git commit  -m "log"

4.查看提交状态

git status

5.忽略文件或文件夹

新建.gitignore文件,写入要忽略的文件名即可

6.查看三个区域文件的区别

$git diff --staged : workspace VS staged  .
$git diff --cached :staged  VS local repo

7.回滚 reset

git reset 三种模式
git reset --mixed 保留工作区源码,临时区和本地仓库回滚
git reset --soft  保留工作区和临时区源码,本地仓库回滚
git reset --hard 工作区,临时区,本地仓库都回滚

git reset --hard HEAD^ 回滚所有内容到上一个版本,后边可加上文件名
git reset --hard HEAD~3回滚到上3个版本
git reset --hard  origin/master 回滚到和远程仓库一致

8.删除移动 rm mv

删除但未提交到本地仓库,这时如果想找回文件,使用git checkout filename

共享及更新项目

1.从远程仓库中更新 fetch pull

git fetch origin 相当于是从远程获取最新版本到本地,不会自动merge
git pull origin 相当于是从远程获取最新版本并merge到本地

2.提交到远程仓库

git push origin master

3.远程仓库 remote

列出远程仓库
git remote
git remote -v 显示远程地址

//添加远程仓库
git remote add pb git://github.com/sundyhome/ticgit.git
git remote rename pb paul
git remote rm paul
git remote show origin

观察比较 log diff

查找tag对应的commit id
 git log --oneline --decorate

分支管理及合并

1.分支branch

git branch branchname创建分支

查看
git branch 列出分支
git show-branch 列出分支,并列出差异
git diff branch1 branch2
git whatchanged

2.切换分支checkout

3.分支合并merge

git merge "merge branch1 to master" HEAD branch1


另一种做法
git checkout master
git pull . branch1

4.版本tag

git tag -a ver1.0 -m "my version 1.0"

//show ver1.0 命令查看相应标签的版本信息,并连同显示打标签时的提交对象。
git show ver1.0

//switch ver1.0
git checkout ver1.0