Linux - git notes
来源:互联网 发布:服务器装centos 编辑:程序博客网 时间:2024/05/18 14:12
* git config --global core.editor vim
* git config --global user.name nixawk
* git config --global user.email nixawk@demo.com
* git config --global color.diff auto
* git config --global color.status auto
* git config --global color.branch auto
#### 在工作目录中初始化新仓库
* git init
* git add README.md
* git commit -m 'new project'
#### 从现有仓库克隆
* git clone git://github.com/someone/project.git
* git clone git://github.com/someone/project.git myproject
#### 检查当前文件状态
* git status
#### 跟踪新文件
* git add README.md
#### 忽略某些文件
* cat .gitignore
```
# 此为注释 – 将被 Git 忽略
# 忽略所有 .a 结尾的文件
*.a
# 但 lib.a 除外
!lib.a
# 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO
/TODO
# 忽略 build/ 目录下的所有文件
build/
# 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt
doc/*.txt
# ignore all .txt files in the doc/ directory
doc/**/*.txt
```
#### 查看已暂存和未暂存的更新
* git diff
* git diff --cached
#### 提交更新
* git commit
#### 移除文件
* git rm README.md
* git rm -f README.md
#### 移动文件
* git mv README.md README.txt
#### 查看提交历史
* git log
* git log -p -2
* git log --pretty=format:"%h - %an, %ar : %s"
#### 修改最后一次提交
* git commit -m 'commit message'
* git add README.md
* git commit --amend
#### 取消已经暂存的文件
* get reset HEAD README.md
#### 取消对文件的修改
* git checkout -- README.md
#### 查看当前的远程库
* git remote -v
#### 添加远程仓库
* git remote add dev git://github.com/someone/project.git
#### 从远程仓库抓取数据
* git fetch dev
#### 推送数据到远程仓库
* git push [remote-name] [branch-name]
* git push origin master
#### 查看远程仓库信息
* git remote show origin
#### 远程仓库的删除和重命名
* git remote rename dev development
#### 列显已有的标签
* git tag
* git tag -l 'v1.4.2'
#### 查看分支
* git branch
* git branch -v
* git branch --merged
* git branch --no-merged
#### 添加分支
* git branch dev
* git checkout -b dev
#### 切换分支
* git checkout dev
#### 合并分支
* git checkout master
* git merge dev
#### 删除分支
* git branch -d dev
* git branch -D dev
#### 推送本地分支
* git push origin dev
#### 跟踪远程分支
* git checkout --track origin/dev
#### 删除远程分支
* git push origin :dev
#### 记录回滚
git reset --hard old-commit-id
git push -f origin branch
#### GITHUB SSH KEY
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/yourPrivKey
git remote set-url origin git@github.com:<Username>/<Project>.git
> create a new git repository
```
git config --global user.name "someone"
git config --global user.email "someone@demo.com"
mkdir project
cd project
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:someone/project.git
git push -u origin master
```
> http://www.git-scm.com/book/
https://help.github.com/articles/generating-ssh-keys/
http://stackoverflow.com/questions/14762034/push-to-github-without-password-using-ssh-key
0 0
- Linux - git notes
- git-Notes
- GIT Notes
- Git Notes
- Linux Notes
- linux notes
- Linux Notes
- linux notes
- linux notes
- 【Git Notes】 置顶索引
- Git study notes
- Mini-Notes:Git
- Git Technical Notes
- Notes on git
- Git Learning Notes
- GIT Study Notes
- notes for git
- Git study notes
- 指针和指针强制转换
- Z-Stack协议学习笔记2--OSAL系统框架专题
- 杭电oj-acm steps-1.2
- Boost::asio库的网络编程学习(转)
- 五种常用基数估计算法效果实验及实践建议
- Linux - git notes
- POJ 1178 Camelot(DP + 枚举)
- Sencha ----Controller官网API翻译
- Unity3D地形创建
- CentOS更改yum源与更新系统
- 微信公众平台开发:初体验
- 在Java中实现浮点数的精确计算
- SSH框架总结(框架分析+环境搭建+实例源码下载)
- Codeforces Round #257 (Div. 2) D