Linux Git commands
来源:互联网 发布:花屋小三郎 知乎 编辑:程序博客网 时间:2024/05/16 08:04
简介:
Git 是一种分布式的版本控制系统,客户端并不只是提取完整的最新版本的文件快照,而且把完整的代码仓库完整的镜像下来。
Git 的工作原理:
Git的简单应用:
1. 公钥与私钥 ssh -keygen
2. 创建服务器端代码仓库(not verified)
sudo useradd git
sudo passwd git
sudo mkdir -p /var/git.server/project1
cd /var/git.server
sudo chown git project1
sudo chgrp git project1
cd project1
$ cat > .gitignore << end
> *.[oa]
> *.so
> *~
> !a.so
> test
> tmp/
> end
sudo su git
sudo git --bare init
// 从服务器端clone代码库到客户端
git clone git@192.168.1.X:/var/git.server/project1 project1
git add a.txt // 添加新增文件
git add . // 添加新增文件
git commit -am "New Commit" // 提交版本
git commit --amend -am "Rename New Commit" // 重新提交,更改注释
git checkout -b abeen // 创建abeen分支
git branch // 查看所有分支
git checkout master // 切回master分支
git merge abeen // 合并abeen分支到master
git pull origin master// 从服务器刷新最新代码
git push origin master// 将代码刷新到服务器
git reset HEAD^ // 恢复到上次提交状态(HEAD^、HEAD~4、commit-id、tag)
git status // 查看当前track状态
git log // 查看提交日志
git log -3 // 查看最后三条提交日志
git log -3 --stat // 显示简单的统计信息
git log -l -p // 显示修改的详细信息
/ 阶段性版本
git tag v0.9 // 创建标签
git tag // 显示所有标签
git log v0.9 // 用标签显示提交状态
git show --stat v0.9 // 用标签显示提交基本信息
git rm filename // 删除代码库里的文件
git checkout HEAD^ -- filename // 恢复文件
git rm --cache filename // 只从代码库删除文件,工作目录文件成未跟踪状态
git checkout HEAD^ -- filename // 签出以前的某个版本
git mv filename dirname // 移动文件
git show filename // 查看某个提交版本的具体信息
git diff HEAd^ filename // 比较版本差异
git reset -hard commit_id //恢复之前版本
远程仓库
git remote // 查看当前远程库
git remote -v (verbose简写)// 显示对应的克隆地址
git remote add [shortname] [ulr] // 添加远程仓库
git fetch [remote-name] // 获取远程仓库信息
git push origin master // 推送数据到远程仓库
git remote show [remote-name] // 显示远程仓库信息
git remote rename pb paul // 修改远程仓库对应名称
git remote rm paul // 删除远程仓库
---------------------------------------------
Refer to:
http://www.open-open.com/lib/view/open1332904495999.html
- Linux Git commands
- git commands
- Git commands
- git commands
- Git commands
- Git commands / git log
- Linux Commands
- Linux Commands
- linux commands
- Linux Commands
- linux commands
- linux commands
- Linux commands
- linux commands
- Linux Commands
- Linux commands
- Linux commands
- Linux Commands
- POJ-World Cup Noise 简单DP
- “结巴”分词:做最好的Python分词组件
- 求树的最大路径和
- xargs用法
- 关于NFC技术的问题汇总
- Linux Git commands
- PHP识别电脑还是手机访问网站
- Kleinrock和互联网的故事
- linux 下添加环境变量
- LinearLayout详解一:LinearLayout的简介
- ndk-stack需要log作为JNI输入来分析
- VC++寻找进程是否存在
- python的nltk中文使用和学习资料汇总帮你入门提高
- NFC协议学习分享