zoukankan      html  css  js  c++  java
  • git应用基础配置

    1.注册github账号。注册的时候会要求输入用户名和email这是配置git必须的要素

    捕获2222

    2.在使用git的时候首先需要把注册时候配合的用户名和密码填在git仓库的配置文件里,如下

    harvey@harvey:~/node/.git$ git config user.name "×××××××" #配置git用户名,注册github的时候会要求输入的
    harvey@harvey:~/node/.git$ git config user.email z××××××@qq.com #配置git邮箱 注册github的时候也会要求输入的

    3.创建一个新的空的仓库

    cd  ~/node #切换到要求备份的文件夹
    git init #初始化一个新的仓库

    4.配置忽略管理的文件列表

    harvey@harvey:~/node$ vim .gitignore #在.git所在的文件夹里创建一个和.git在同级目录下的文件.gitignore 文件
    
    harvey@harvey:~/node$ git status  #查找在Untrack状态的文件,可以根据格式添加到.gitignore文件里,就不会再在Untrack状态出现了
    # On branch master
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #    node_modules/
    #    ttt.doc
    nothing added to commit but untracked files present (use "git add" to track)
    
    harvey@harvey:~/node$ git add .gitignore #同步忽略配置信息让所有使用本仓库的用户自动忽略相应文件
    harvey@harvey:~/node$ git status #查看到效果已经生效
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #    new file:   .gitignore
    #

    5.添加要求同步管理的数据交给git管理

    #####################################################
    harvey@harvey:~/node$ git status #首先查看一下刚创建的git的状态
    # On branch master
    #
    # Initial commit #记录更改的状态,现在是初始状态
    #
    # Untracked files:   #发现没有被跟踪的文件列表是 README httptest.js和node_modules文件夹
    #   (use "git add <file>..." to include in what will be committed)
    #
    #    README
    #    httptest.js
    #    node_modules/
    nothing added to commit but untracked files present (use "git add" to track)  #nothing表示现在是个空的git仓库
    #####################################################
    harvey@harvey:~/node$ git add *.js README #生命要把js文件和ReadMe文件交给仓库管理
    harvey@harvey:~/node$ git status
    # On branch master
    # Untracked files: #git add后发现没被跟踪的文件只有node_modules文件夹,说明 add的结果是httptest.js和README文件已经被跟踪了
    #   (use "git add <file>..." to include in what will be committed)
    #
    #    node_modules/
    nothing added to commit but untracked files present (use "git add" to track)
    #####################################################
    harvey@harvey:~/node$ git commit 
    [master (root-commit) d726721] ?芒??碌??禄麓??谩陆禄碌??媒戮? ??js??录镁潞?README????
     2 files changed, 8 insertions(+)
     create mode 100644 README
     create mode 100644 httptest.js 
    #git commit后提示创建了mode 这就是新提交的快照文件了
    ###############添加一个新的js文件测试##############################
    harvey@harvey:~/node$ git add *.js
    harvey@harvey:~/node$ git status
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #    new file:   node3.js #这是新的文件和上次的快照对比的结果
    #
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #    node_modules/ #文件结果不同但是node3.js还不在列表里表明已经被已经add了,如果被提交commit后就可以直接不会有差别的信息了
    #说明可以通过state的两个列表信息就可以表示判断是在为跟踪_已跟踪_提交三种状态的哪一个了

    6.在github自己的账号里创建一个远程仓库,然后就能获得一个远程仓库的地址

    7.把本地管理的内容同步到远程服务器

    harvey@harvey:~/node$ git remote add origin https://github.com/×××××××/nodejs.git #要往某个远程git服务器上推送内容首先要添加远程仓库
    harvey@harvey:~/node$ git push -u origin master  #添加主分支的内容到服务器

  • 相关阅读:
    my34_脚本冥等添加自动任务-mysql监控部署
    zabbix4.2 安装
    面试题12:字符串无重复子串的最大长度
    面试题11:二叉树的非递归前、中、后、层级遍历
    面试题10:二叉树的最大路径和
    面试题9:数组堆化、堆的插入、堆的删除、堆排序
    面试题8:无序数组的最大差值
    面试题7:判断链表是否有环,返回环的入口点
    面试题6:二叉树最近公共节点(LCA)《leetcode236》
    面试题6:二叉树转单链表
  • 原文地址:https://www.cnblogs.com/zhanghaiyublog/p/3649444.html
Copyright © 2011-2022 走看看