git命令

来源:互联网 发布:ios缓存清理软件 编辑:程序博客网 时间:2024/06/08 18:58

基础命令:

git init 初始化git仓库(创建库)

git status 查看git仓库状态

git add 添加文件到缓存(等待提交)

git rm [--cached] 移除缓存

git commit [-m] 提交文件到库(提交文件)

git log 查看commit日志

  • git branch 分支
  1.  -d | -D [删除 | 强制删除] 分支
  2. -r 查看远程分支

  • git checkout 切换分支
  1. git checkout    [ [-b] branch  |  tag  |   commit_id ] 切换 [ [且创建] 分支 | 标签 | 提交]
  2. git    checkout    [file_name]撤销还原文件(未add缓存区)
  3. git checkout    [ [-b] branch_name]  origin/ [branch_name]把远程分支迁到本地 [-b 并切换到该分支]

  • 合并分支
  1. git merge 按分支类型排序
  2. git rebase 按分支时间排序


git tag 代码标签(版本)

git clone [ https| ssh ] 克隆gitgub上的仓库到本地

git pull origin master 拉取远程仓库代码

git push origin master 推送本地仓库到远程仓库

git remote add [自定义远程仓库名] [https | ssh]关联远程仓库

git remote -v 查看当前项目有哪些远程仓库

git config --global user.name[email] "moon" 查看/修改commit记录的姓名[邮箱]

git config --global alias.co checkout 给命令取别名

git config -l 查看配置文件(~/.gitonfig)

git config --global core.editdor "vim" 修改git默认编辑器

git config --global core.ui true 给终端着色

git config --global core.quotepath false 设置显示中文文件名

git   push   origin   branch_name1:branch_name2 推送本地分支并修改远程分支名

git  push  origin   :branch_name 删除远程分支


Git FLOW
下载: https://github.com/nvie/gitflow
教程: http://stormzhang.com/git/2014/01/29/git-flow/git branch feature/A
git branch hotfix/B
git branch release/1.0
git flow feature start A
git flow feature finish B



******SSH*******
ssh-keygen -t rsa rsa算法生成ssh密钥
ssh -T git@github.com 测试 SSH key 是否添加成功




git命令相关博客:

http://blog.csdn.net/u012556150/article/details/50736896

http://blog.csdn.net/gnnulzy/article/details/52411559


原创粉丝点击