zoukankan      html  css  js  c++  java
  • git 笔记

     
    $ git config --list 
    可以查看配置的一些东西。可以看到user.name 和user.email  分别是什么。。
     
    如果你没有初始化过。那么直接进行初始化:
    $  git config --global user.name "输入你的用户名"
    $  git config --global user.email "输入你的邮箱"
     
     
    1:使用--repalce-all 修改。
    $  git config --global --replace-all user.email "输入你的邮箱" 
    $  git config --global --replace-all user.name "输入你的用户名"
     
    2:再说说git bash和git cmd的区别啊。。简单一句话,,git cmd是git bash的子集。所以直接用git bash就行了。 然后git gui是图形界面。
     

    git 

    版本控制工具,支持该工具的网站有Github、BitBucket、Gitorious、国内的osChina仓库、csdn仓库等等。

    shell

    是linux、unix系统的外壳,也可以理解为命令行,就是你输入并执行命令的地方,git通过命令行和图形界面两种方式使用shell。

    bash

    是shell的一种,最常用的shell之一。

    git Bash

    方便你在windows下使用git命令的模拟终端(windows自带的cmd功能太弱)linux、unix可以直接使用git。

    git shell

    它是安装了git的shell,bash是一种shell。

    mkdir wty 
    cd wty 
    git init 
    git config –list //设置user.email/username等

    编写代码文件后:

    git add . 
    git commit -m “说明标签”

    查看远程仓库

    git remote -v

    添加远程仓库

    git remote add [shortname] [url] 
    git remote add origin https://github.com/用户名/库.git

    //”origin“这个相当于是个别名,你可以自己随便写,也可以写成当前文件夹的名,后面的地址是你在GITHUB刚刚新建的 库 地址, 你建了哪几个库,你到GITHUB找到你建的库,点进去就能看到相应的地址。

    推送数据到远程仓库

    git push [remote-name] [branch-name] 
    git push -u origin master

    推送数据到远程仓库中可能会出现的错误:

    git push -u origin master //会提示输入用户名和密码 
    ! [rejected] master -> master (fetch first) 
    error: 无法推送一些引用到 ‘https://github.com/Lvzwq/zwq.git 
    提示:更新被拒绝,因为远程版本库包含您本地尚不存在的提交。这通常是因为另外 
    提示:一个版本库已推送了相同的引用。再次推送前,您可能需要先合并远程变更 
    提示:(如 ‘git pull’)。 
    提示:详见 ‘git push –help’ 中的 ‘Note about fast-forwards’ 小节。

    输入完之后会出现以上错误。

    然后输入:

    git fetch 
    git merge //会出现错误: 
    fatal:未指定提交并且merge.defaultToUpstream 未设置。

    此时需要重新git add,git commit 
    然后执行:

    git push -u origin master //会出现以下错误: 
    ! [rejected] master -> master (non-fast-forward) 
    error: 无法推送一些引用到 ‘https://github.com/xxxxx/xxx.git 
    提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。 
    提示:再次推送前,先与远程变更合并(如 ‘git pull’)。详见 
    提示:’git push –help’ 中的 ‘Note about fast-forwards’ 小节。

    执行(不必要):

    git config branch.master.remote origin 
    git config branch.master.merge refs/heads/master

    与远程合并:

    git pull 
    git add . 
    git commit -m “second push”

    如何提交到多个远程仓库

    1.

    git remote add oschina https://git.oschina.net/free/Mapper.git 
    git remote add github https://github.com/abel533/Mapper.git 
    git push oschina master 
    git push github master

    2.

    git remote add all https://git.oschina.net/free/Mapper.git 
    git remote set-url –add all https://github.com/abel533/Mapper.git

    如果有多个,按照上面这一个命令进行添加。

    git push all --all

    等同于直接编辑.git/config文件

    [remote “all”] 
    url = https://github.com/abel533/Mapper.git 
    url = https://git.oschina.net/free/Mapper.git

  • 相关阅读:
    Xamarin.Forms添加启动动画
    asp.netcore mvc Json中文乱码
    The database provider attempted to register an implementation of the 'IRelationalTypeMappingSource' service.
    阻塞线程的办法
    日常学习东西
    第三方框架的学习经验
    业余时间作为学习
    UI卡顿以及解决的办法
    Kotlin语言学习
    这两个面试经常被问到两个常见算法
  • 原文地址:https://www.cnblogs.com/fer-team/p/7485928.html
Copyright © 2011-2022 走看看