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

    仅拉取指定分支内容

     git clone -b dev --single--branch git@

    清除缓存

    git rm -rf --cached .
    

    强制覆盖本地

    git fetch --all && git reset --hard origin/master && git pull

    清理未跟踪文件

    git clean -f

    回退到指定版本

    1. 查看所有的历史版本,获取你git的某个历史版本的id, git log
    2. 回退本地代码库:git reset --hard ID
    3. 推送到远程服务器:git push -f -u origin master
    4. 重新拉代码:git pull

    清除本地未提交变化(撤销修改)

    git checkout .

    初始化 

    git init

    配置全局用户名,邮箱

    git config --global user.name "jack"
    git config --global user.email "jack@126.com"
    git config --global --list
     

    对单个项目配置用户名密码

    git config user.name "jack"
    
    git config user.email "gitlab@xx.com"
    
    git config --local --list

    添加

    添加全部
    git add .
    添加指定文件夹
    git add dir

    提交

    git commit -m "提交描述"

    查看当前文件夹状态

    git status

    查看日志

    #当前往后的
    git log
    #所有的
    git reflog

    切换版本(git log 查看版本号)

    git reset --hard  版本号

    克隆

    git clone 链接

    恢复到修改前

    git checkout  文件夹

    推送版本

    git push  origin  master
    git push 仓库地址 分支

    拉取项目

    第一种 
    git pull origin master
    第二种(必须处于相同分支,当前处于dev分支)
    git fetch origin dev
    git merge origin/dev 替换成git rebase origin/dev 不会出现分叉

    远程仓库

    查看 
    git  remote -v
    增加
    git remote add origin  仓库地址
    删除
    git remote remove origin
    远程地址
    git remote show origin

    暂存

     暂存当前修改,  

    暂存
    git stash
    拿回来
    git stash pop
    拿回指定编号
    git stash apply 编号
    列出来
    git stash list
    清空
    git stash clear
    删除指定的
    git stash drop 编号

     分支

    当前代码创建分支
    git branch  dev
    查看分支
    git branch
    切换分支
    git checkout dev
    合并(把dev 合并到master)日志也会被合并
    git branch master
    git merge dev
    删除分支
    git branch -d dev

     标签

    打标签
    git tag -a v1.0 -m "第一个版本"
    查看版本信息
    git show v1.0
    查看本地tag
    git tags -n
    推到远程
    git push origin  --tags
    git pull origin  --tags
    
    切换版本
    git checkout v1.0
    
    拉取指定版本
    git clone -b v1.0  路径

     rebase

    git checkout master
    
    git rebase dev

     贡献开源代码

    1,fork
    
    2,new pull request
    
    不用输入密码登录
    
    https://用户名:密码@路径
  • 相关阅读:
    从句分析
    artDialog ( v 6.0.2 ) content 参数引入页面 html 内容
    Java实现 LeetCode 13 罗马数字转整数
    Java实现 LeetCode 13 罗马数字转整数
    Java实现 LeetCode 13 罗马数字转整数
    Java实现 LeetCode 12 整数转罗马数字
    Java实现 LeetCode 12 整数转罗马数字
    Java实现 LeetCode 12 整数转罗马数字
    Java实现 LeetCode 11 盛最多水的容器
    Java实现 LeetCode 11 盛最多水的容器
  • 原文地址:https://www.cnblogs.com/huay/p/11300350.html
Copyright © 2011-2022 走看看