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

    序号 命令 作用 示例
    1  git clone  克隆版本库(下载 github 上的项目)  git clone https://github.com/huanggyaaa/vue-router-simple-demo.git
    2  git remote  版本库相关设置

     git remote -v  //查看远程仓库, 如果有多个显示列表

     git remote add origin https://github.com/huanggyaaa/vue-router-simple-demo.git  //添加远程仓库, origin 是别名

     git remote rm origin  // 删除 origin 这个远程仓库

     3   git add 

     提交到暂存区(被跟踪)

     git add .  // 讲所有内容保存到暂存区, 不包括删除的文件

     git add *css  // 把 css 结尾的文件添加到暂存区

     git add hello*  // 把 hello 开头的文件保存到暂存区

     git add -u  // 只保存修改过的文件到暂存区

     git add -A  // git add. 和 git add -u 功能集合

     4  git commit  提交到版本库

     git commit -m "first commit"  // 将暂存区的内容提交到版本库

     git commit -a -m "second commit"  // 将所有已跟踪的文件提交到版本库; 跳过 git add 命令

     5  git push 

     提交到远程仓库

     git push origin master  // 把 master 分支提交到 origin 远程仓库, master 分支如果不存在会被新建

     git push -u origin master  // 和上面的命令的区别是: 把 origin 设为默认远程仓库

     6  git pull

     更新远程仓库代码到本地并合并

     git pull  // 更新远程仓库的所有分支到本地并合并本地的代码, 如果远程和本地仓库某个文件同时做了修改就会报错

     7  git fetch

     更新远程仓库代码到本地

     git fetch origin master  // 从 origin 远程仓库获取 master 分支到 本地仓库的 master 分支(不会直接合并)

     git log -p master.. origin/master  // 比较本地和远程仓库的区别

     git merge origin/master  // 合并

    8 git branch

    分支操作

     git branch  // 查看本地分支

     git branch -a  // 查看远程和本地分支

     git branch dev  // 创建 dev 分支

     git checkout dev  // 切换到 dev 分支, 工作区代码会跟着发生变化

     git branch -d dev   // 删除 dev 分支

     git push dev origin  // 把 dev 分支提交到 origin 这个远程库

     撤销修改

      git log 列出提交的commit_id

      git reset --hard commit_id  // 撤销某个版本的提交, 工作区也提交, 意味着工作白费了

      git reset --soft

    代码量

    git log  --author="huanggyaaa" --format='%aN' | sort -u | while read name; do echo -en "$name	"; git log --author="$name" --pretty=tformat:  --since ==2019-1-1 --until=2019-12-31 --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s
    ", add, subs, loc }' -; done
  • 相关阅读:
    [USACO17FEB]Why Did the Cow Cross the Road III S
    [POI2015]PIE
    GSS3
    Bzoj3203: [Sdoi2013]保护出题人 凸包 + 三分
    斜率优化
    fread优化读入
    [USACO09JAN]安全出行Safe Travel 最短路,并查集
    zookeeper单机模式实现分布式,开发部署测试模式机器有限情况
    解决 jmeter An error occurred: Error while processing samples:Mismatch
    python 垃圾回收解析
  • 原文地址:https://www.cnblogs.com/huanggy/p/10081365.html
Copyright © 2011-2022 走看看