• git 常用命令


    git status 查看工作区和暂缓区状态
    git add 将工作区放入暂缓区
    git commit 将暂缓区放入 版本区
    git add 把修改过的文件全部提交到暂缓区
    git commit -m "提交时写备注" 不弹文档
    git commit -a -m "提交时写备注" 直接把工作区提交到版本区
    git log 查看提交的历史命令
    git clone +地址 克隆

    进入项目
    git config --global user.name "名字"
    git config --global user.email "邮箱"
    git config --global user.email 查看
    git config --list 查看所有
    git diff 工作区与暂缓区的对比
    git diff --cached 暂缓区与 版本区的对比
    也可用 git diff --staged

    git add .修改过的文件全部提交到暂存区
    git commit -m "提交备注" 暂存区提交到版本区,不弹出,直接写备注。
    git commit -a -m "提交备注" 从本地 提交到暂存区 在提交版本区连写。(不能跳过暂存区,直接提交到版本区)

    文件对比
    git diff 工作区与暂存区之间的对比
    git diff --cached (git diff --staged)暂存区与版本区之间的对比
    git diff master 工作区与版本区的对比

    撤销
    git reset HEAD "文件名字" 从暂存区还原到工作区
    git checkout "文件名字" 将版工作区还原到版本区的状态
    git commit --amend 将上次提交撤回,和这次的一起 提交, 用一个版本号

    删除
    git rm 文件名 删除暂存区的文件。
    git rm -f 文件名 工作区不删除的情况下 删除暂存区的文件。(工作区和暂存区一起删除)
    git rm --cached 文件名 工作区不删除的情况下 删除暂存区的文件。 ( 只删除暂存区,工作区不删除)

    恢复
    git checkout 版本id 要恢复的文件
    git reset --hard 版本id 直接恢复到上一个版本
    git reset --hard HEAD^ 回到想一个版本
    git reset --hard HEAD~数字 回到前面几个版本
    git reflog 查看最近操作信息
    git reset --hard 版本id 回到 以前的版本


    同步到远程仓库
    git remote 查看远程仓库的名字
    git remote -v 查看远程仓库对应的地址
    git push origin(仓库名) master(分支名) 同步到gitgub 上远程仓库上

    更新本地(解决多人冲突)
    git fetch 拉取远程仓库的文件
    git diff master origin/master 查看具体冲突的内容
    git merge origin/master 本地的与远程仓库合并
    git pull 拉取并合并
    开源项目协作

    分支
    git branch 查看分支
    git branch 分支名字 创建分支
    git checkout 分支名字 切换分支
    git checkout -b 分支名字 创建新分支 并切换到这个新键的分支
    git merge 分支名字 合并分支
    git branch --merged 查看当前分支下合并的分支
    git branch --no-merged 查看当前分支下没有合并的分支
    git branch -d 分支名字 删除分支
    (把有冲突的文件列出来,手工解决冲突之后然后在提交)

    将本的分支创建到github 上
    git push origin(仓库名) master(分支名) 同步到gitgub 上远程仓库上
    github上的标签
    git tag 标签名字 创建标签
    git push origin 标签名字 添加到远程仓库

    ls 查看目录结构
    mkdir 创建文件夹

    git reset --hard 4a49fd11d0473083e29de536d78499b00436ce6d

    git push -f -u origin master

  • 相关阅读:
    进程
    Visual Studio Code 使用教程
    C# 多线程中的lock与token模式
    JavaScript中的多态
    简说GC垃圾回收
    C# 简单的SQLHelper
    JavaScript中addEventListener/attachEvent 与内联事件
    JavaScript中事件冒泡与事件捕获
    ASP.Net ScriptManager 与 UpdatePanel
    Nhibernate 使用sql语句查询
  • 原文地址:https://www.cnblogs.com/nmxs/p/6641914.html
Copyright © 2020-2023  润新知