zoukankan      html  css  js  c++  java
  • git 简单使用

    创建新分支:git branch branchName

    切换到新分支:git checkout branchName

    然后 ,上面两个命令也可以合成为一个命令:

    git checkout -b branchName

    合并分支:

        git checkout master

        git merge newbranch  (将newbranch合并入master分支)

    查看分支:

        git branch

    git add                  

      该命令实际上就是把要提交的所有修改放到暂存区(Stage),然后,执行git commit就可以一次性把暂存区的所有修改提交到分支。

    git checkout branch -- filename        

        将branch 分支中的 filename 文件检出,替换暂存区和工作区中相应的文件。注意会将暂存区和工作区中的filename文件直接覆盖。

    git checkout  commit_id file_name  

        取文件file_name的某个commit_id的版本。commit_id为 git commit 时的sha值。

    git checkout .                                    

        注意git checkout 命令后的参数为一个点(“.”)。这条命令最危险!会用暂存区的所有文件直接覆盖本地文件

    回退版本:

        git reset --hard commit_id    (彻底回退到某个版本,本地的源码也会变为上一个版本的内容)

        git push origin HEAD --force

    删除远程分支:

        git push origin :branch-name
        冒号前面的空格不能少,原理是把一个空分支push到server上,相当于删除该分支。

    删除本地分支:

        git branch -d branchName

    拉取线上分支到本地:

        git pull <远程主机名> <远程分支名>:<本地分支名>   该命令会合并线上分支和本地当前分支,同时会生成新的本地分支

        或者

     git checkout -b angular
     git pull origin angular

    创建暂存区:
    git stash

    查看暂存区:
    git stash list

    恢复暂存区代码到工作区,同时删除暂存区:
    git stash pop [--index] [<stash>]

    根据暂存区创建分支:
    git stash branch <branchname> <stash>


  • 相关阅读:
    HTTP状态码
    CentOS 7 上安装vim(默认未安装)
    yum安装提示Another app is currently holding the yum lock; waiting for it to exit...
    CentOS 7 安装telnet服务
    shell编程
    shell基础
    ssh相关命令
    ssh无密码连接
    centos7小命令
    日志管理
  • 原文地址:https://www.cnblogs.com/olivetree123/p/4801581.html
Copyright © 2011-2022 走看看