zoukankan      html  css  js  c++  java
  • git和repository命令

    git常用命令
     
    git log         // 查看当前库的git log信息
    git status ./   // 查看当前库的状态
    git diff ./     // 比较当前库的修改情况
    git add ./      // 将当前库的代码修改提交到暂存区
    git commit ./   // 将代码提交到本地分支
    git commit --amend ./   // 追加修改
    git reset HEAD~1    // 将当前库恢复到HEAD的上一个版本1234567
    其他命令
     
    git config -l // 参看配置信息
    git show HEAD^ // 查看HEAD的上一个版本信息
    git show HEAD~4 // 查看HEAD的上溯4代的信息
    git reset --hard HEAD^^ // 回退两个版本
    git reset --hard 8308f03 // 回退到指定的commitID前7位的版本
    git clean -dfx //清除库上没有的东西
    git remote -v //  参看远程仓库
    git branch -a // 参看远程分支
    git log --oneline --decorate --graph --all // 图像显示git log信息
    git log --pretty=format:"%h - %cd %s" --graph // 列出指定格式的log
    git log -since="2 weeks ago" // 显示2周前到现在所有的历史记录
    远程同步
    # 下载远程仓库的所有变动
    $ git fetch [remote]
    # 显示所有远程仓库
    $ git remote -v
    # 显示某个远程仓库的信息
    $ git remote show [remote]
    # 增加一个新的远程仓库,并命名
    $ git remote add [shortname] [url]
    # 取回远程仓库的变化,并与本地分支合并
    $ git pull [remote] [branch]
    # 上传本地指定分支到远程仓库
    $ git push [remote] [branch]
    # 强行推送当前分支到远程仓库,即使有冲突
    $ git push [remote] --force
    # 推送所有分支到远程仓库
    $ git push [remote] --all
    撤销
     
    # 恢复暂存区的指定文件到工作区
    $ git checkout [file]
    # 恢复某个commit的指定文件到暂存区和工作区
    $ git checkout [commit] [file]
    # 恢复暂存区的所有文件到工作区
    $ git checkout .
    # 重置暂存区的指定文件,与上一次commit保持一致,但工作区不变
    $ git reset [file]
    # 重置暂存区与工作区,与上一次commit保持一致
    $ git reset --hard
    # 重置当前分支的指针为指定commit,同时重置暂存区,但工作区不变
    $ git reset [commit]
    # 重置当前分支的HEAD为指定commit,同时重置暂存区和工作区,与指定commit一致
    $ git reset --hard [commit]
    # 重置当前HEAD为指定commit,但保持暂存区和工作区不变
    $ git reset --keep [commit]
    # 新建一个commit,用来撤销指定commit
    # 后者的所有变化都将被前者抵消,并且应用到当前分支
    $ git revert [commit]
    # 暂时将未提交的变化移除,稍后再移入
    $ git stash
    $ git stash pop12345678910111213141516171819202122232425262728293031
     
    repo常用命令
     
    repo init -u URL -b ........ // 创建.repo
    repo upload // 将代码提交到gerrit.
    repo abandon master // 放弃master分支
    repo forall -c "git reset --hard HEAD" // 所有代码执行git命令,回退到HEAD
    // repo sync相当于git clone会把repository中的所有内容拷贝到本地,非首次运行repo sync相当于更新和合并.
    // repo sync会更新.repo下面的文件,如果在merge的过程中出现冲突,这需要手动运行git rebase --continue.
    repo sync -c -j 4
    repo start master --all // 创建新分支
  • 相关阅读:
    查看电脑或者服务器sqlserver端口命令
    cvc-elt.1: Cannot find the declaration of element 'beans'Failed to read schema document 'http://www.springframework.org/schema/beans/spring- beans-3.0.xsd'
    彻底卸载注册表、流氓软件的工具Uninstall Tool
    sqlserver安装报错:an error was encountered 数据无效
    导入虚拟机vmware,此主机支持Intel VT-x,但Intel VT-x处于禁用状态和黑屏
    设计模式----观察者模式通俗实例
    设计模式----策略模式通俗实例
    设计模式----代理模式通俗实例
    简单的纯js三级联动
    linux安装windows启动盘
  • 原文地址:https://www.cnblogs.com/wdyaoyao/p/10820181.html
Copyright © 2011-2022 走看看