zoukankan      html  css  js  c++  java
  • 第一章 git指令与设置

    相关指令:

      1.从远程的master分支上创建新的分支,此时新分支内容与master分支内容相同:

        git checkout master;

        git branch newbranch;

        git checkout newbranch;

        git commit -a -m 'new branch';

        git push origin newbranch;

      2.将一个新增的文件a.txt提交到本地仓库:

        git add a.txt

      3.撤销commit操作

        git reset --hard:重设(reset) index和working directory,自从<commit>以来在working directory中的任何改变都被丢弃,并把HEAD指向<commit>。 

        git reset --soft:index和working directory中的内容不作任何改变,仅仅把HEAD指向<commit>,执行完毕后,自从<commit>以来的所有改变都会显示在git status的"Changes to be committed"中。

        git reset --mixed:仅reset index,但是不reset working directory。这个模式是默认模式,working directory中文件的修改都会被保留,不会丢弃,但是也不会被标记成"Changes to be committed"。

        git revert:通过创建一次新的commit来撤销一次commit所做出的修改。

        关于撤销与工作区的解释,见 第二章 git 工作区与reset,revert

          4.删除分支

        删除远程仓库分支:git push origin –-delete 分支名

        删除本地已合并分支: git branch –d 分支名

        删除本地未合并分支: git branch –D 分支名

    ssh免密码登陆:

      1.用ssh-keygen生成sshke

         ssh-keygen -t rsa -C "email" -f "d:id_rsa"

        "email"是个人邮箱,"d:id_rsa"是生成的sshkey文件

      2.输入私钥密码(可直接按回车留空),出现如下界面:

        

      3.最后生成两个文件id_rsa和id_rsa.pub,把这两个文件放到“c:usersuname.ssh”文件夹下

      4.打开id_rsa.pub,把文本添加到git的公钥列表中

         

    https免密码登陆:

      首次使用时输入完用户名密码后,使用git config credential.helper store指令记住用户的登陆。

    git指令简写设置:

       1.打开D:Program Files (x86)Gitetc(自己的git安装路径)下的gitconfig文件,添加如下语句:     

       [alias]
        co = checkout
        ci = commit
        st = status
        pl = pull
        ps = push
        dt = difftool
        l = log --stat
        cp = cherry-pick
        ca = commit -a
        br = branch

      

      

  • 相关阅读:
    第十四周学习进度
    第十三周学习进度
    第十二周学习进度条
    从用户体验角度评价所使用的输入法。
    个人博客十
    数组测试 --Junit
    看了build to win之后的感想
    思考题
    数组中最大子数组之和
    使用Espresso进行UI测试
  • 原文地址:https://www.cnblogs.com/jian-xiao/p/5719699.html
Copyright © 2011-2022 走看看