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

    查看仓库大小

    du -sh
    

    向仓库强制推送所有的变化:

    git push origin master --force
    

    删除不存在对应远程分支的本地分支

    使用 git remote prune origin 可以将其从本地版本库中去除。

    重命名本地分支 -m

    git branch -m devel develop
    

    完成撤销,同时将代码恢复到前一commit_id 对应的版本。

    git reset --hard commit_id
    

    完成Commit命令的撤销,但是不对代码修改进行撤销,可以直接通过git commit 重新提交对本地代码的修改。

    git reset commit_id
    

    只获取最新的 commit 记录

    git clone https://github.com/SuperAL/splice.git --depth=1
    

    --depth=1,代表只拉取最新一次提交。

    查看remote地址,远程分支,还有本地分支与之相对应关系等信息

    git remote show origin
    

    查看远程仓库已经不存在的分支

    git remote prune origin
    

    拉取远程到本地,并更新本地和远程的对应关系,同步时顺便删除远程已删除的分支

    git fetch -p
    

    删除本地分支(远程已经没有的对应的分支)

    git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
    

    看下自己最近的一些删除的提交

    git fsck --lost-found
    

    merge 回退

    git merge --abort
    

    删除本地远程不存在的分支

    git remote prune origin
    

    git fetch -p

    删除远程分支

    git push origin --delete <BranchName>
    

    git clone 时输错密码

    windows系统执行命令: git credential-manager uninstall
    mac系统命令为: git credential-osxkeychain uninstall

    重新设置本机git配置

    git config --global credential.helper store
    

    git配置的http或https代理

    git config --global http.proxy 127.0.0.1:51441 # 设置代理
    git config --local http.proxy 127.0.0.1:51441 # 设置本仓库代理
    
    git config --global --unset http.proxy # 删除全局代理
    git config --local --unset http.proxy # 删除本地仓库代理
    

    git 查看分支并格式化时间

    git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'
    

    清除仓库中的文件

    git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.class'   --prune-empty --tag-name-filter cat HEAD -- --all
    

    忽略某些文件

    git update-index --assume-unchanged ./config/index.js
    

    git 无历史合并

    git merge master --allow-unrelated-histories
    
  • 相关阅读:
    ios 重构笔记
    ios uiwindow笔记
    ios静态库笔记
    ios app提交之前需要哪几个证书
    int、long、long long取值范围
    字节概述
    序列化概述
    LeetCode 最大连续子数列值
    198. LeetCode 打家劫舍
    git自定义关键字
  • 原文地址:https://www.cnblogs.com/daowangzhizhu-pt/p/12118532.html
Copyright © 2011-2022 走看看