zoukankan      html  css  js  c++  java
  • git 常用命令

     1. 配置

    git config --list
    git config --global http.sslverify false
    git config --global user.name "Firstname Lastname"
    git config --global user.email your_email@youremail.com

    2. 文件状态

    -> 查看文件改动

    git status

    注意,git status 不记录空的文件夹

    -> 删除所有没有被 git 记录的文件和文件夹

    git clean -fd

    3. 查看提交日志 (commit, log, tag)

    -> 查看所有提交的日志

    git log

    -> 查看第一条 log

    git log -1

    -> 查看某个文件的所有提交的日志

    git log <file>

    -> 查看某个提交 (commit) 的详细信息

    git show <commit hash>

    -> 查看某个 tag 信息

    git show <tag>

    -> 比较两个 commit 的差异

    git diff <commit 1> <commit 2>

    4. 分支 (branch)

    -> 查看本地分支

    git branch

    -> 查看远程分支

    git branch -r

    -> 查看本地和远程所有分支

    git branch -a

    -> 创建一个本地分支 xxx

    git branch <xxx>

    -> 切换到分支 xxx

    git checkout <xxx>

    -> 删除本地分支 xxx

    git branch -d <xxx>

    -> push 本地分支到远程

    git push origin xxx

    -> 删除远程分支

    git push --delete origin xxx

     5. Checkout 和 Pull, Push

    -> Checkout 某个提交的版本

    git checkout <commit>

    -> Checkout 某个文件最新版本,这个操作将放弃本地对这个文件的修改

    git checkout <file>

    -> 更新在最新版本

    git pull

    -> 添加一个新的文件到 git

    git add -N file

    -> 查看远程的 hosts

    git remote -v

    -> 提交 commit

    git commit -a -m "msg"

    -> push commit 到远程服务器

    git push

    -> push branch foo 到远程服务器

    git push origin foo

    6. git stash

    -> 保存本地的修改

    git stash

    -> List 本地保存的改动

    git stash list

    -> 应用本地 stash 里的修改到当前的 code

    git stash pop stash@{0}

    7. tag 和 release

    -> 显示所有 tag

    git tag

    -> 显示 tag 1.4*

    git tag -l '1.4*'

    -> 显示某一个tag 信息

    git show <tag>

    -> 添加一个详细 tag, 名字是 v1.4,描述是 'my version 1.4'

    git tag -a v1.4 -m 'my version 1.4'

    -> push tag 到远程,成为一个 release

    git push origin <tag>

     -> push 所有 tags 到远程

    git push origin --tags

    // BACKUP
    git checkout Impala2.6-gcc4.9
    git pull
    git branch Impala2.6-gcc4.9_bak
    git push origin Impala2.6-gcc4.9_bak:Impala2.6-gcc4.9_bak

    // RESET on local
    git checkout Impala2.6-gcc4.9
    git pull
    git log
    git reset --hard 282cbfbca0f8c9f1aaa7a4a224e3c61aaa576c5c

    // DELETE remote
    git push origin :Impala2.6-gcc4.9

    // Push to remote
    git push origin Impala2.6-gcc4.9

    create branch from another repository
    git remote add <fork> <repo url>
    git fetch <fork>
    git checkout -b <main> <fork/master>
    git push origin <main>

     

  • 相关阅读:
    伸缩盒 Flexible Box(旧)
    js 事件绑定
    vertical-align 垂直居中
    小程序de 一些经验1
    更新一下 我的红包雨
    HTML元素坐标定位,这些知识点得掌握
    JS实现-页面数据无限加载
    em和px的区别一次彻底搞清楚!
    js模糊查询
    phpmyadmin-您可能正在上传很大的文件,请参考文档来寻找解决方法
  • 原文地址:https://www.cnblogs.com/weiweifeng/p/8125179.html
Copyright © 2011-2022 走看看