• Git之项目使用


      现在最为盛行的版本控制器,非git莫属了, 那就看看在项目中我们是如何使用它的吧

      一. 在已经存在秘钥对的情况下,我们需要在本地进行相关配置

      

    git config --global user.name "名称"
    git config --global user.email "邮箱地址"

      二.项目处理

       1.开始对新项目进行初始化

    git clone git@gitlab.com:#####/##.git  //检出项目
    cd poi //进入项目
    touch README.md 
    git add README.md //添加新文件
    git commit -m "add README"  //进行提交
    git push -u origin master //推到主分支

      2. 已经存在的项目目录

    cd existing_folder
    git init
    git remote add origin git@gitlab.com:#####/##.git
    git add .
    git commit -m "Initial commit"
    git push -u origin master

      3. Git版本已经存在

    cd existing_repo
    git remote rename origin old-origin
    git remote add origin git@gitlab.com:#####/##.git
    git push -u origin --all
    git push -u origin --tags

      4. 修改的内容回退

    # 对于未使用git add添加的文件(该文件之前已经存在git)
    git checkout -- config/test.ini  #使用--  否则成为切换分支   
    #放弃所有的修改
    git checkout .     

       5. Git远程仓库地址变更本地如何修改

    1. 通过命令行直接修改
    进入git_test根目录
    git remote 查看所有远程仓库, git remote xxx 查看指定远程仓库地址
    git remote set-url origin http://192.168.100.235:9797/john/git_test.git
    
    2.通过命令先删除再添加远程仓库
    进入git_test根目录
    git remote 查看所有远程仓库, git remote xxx 查看指定远程仓库地址
    git remote rm origin
    git remote add origin http://192.168.100.235:9797/john/git_test.git
    
    3.直接修改配置文件
    进入git_test/.git
    vim config
    
    [core]
    repositoryformatversion = 0
    filemode = true
    logallrefupdates = true
    precomposeunicode = true
    [remote "origin"]
    url = http://192.168.100.235:9797/shimanqiang/assistant.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
    remote = origin
    merge = refs/heads/master
    
    修改 [remote “origin”]下面的url即可

      其他:

      1. 配置相关

        

    git config //config配置指令
    
    config 配置有system级别 global(用户级别) 和local(当前仓库)三个 设置先从system-》global-》local  底层配置会覆盖顶层配置 分别使用--system/global/local 可以定位到配置文件
    
    git config --system --list  //查看系统配置
    
    git config --global  --list  //查看用户配置
    
    git config  --local   --list  // 查看当前仓库配置信息
    
    //常见配置操作
    
    git config --global user.name '用户名称' //lanlang
    git config --global user.email '邮箱' //liaotiam@126.com
  • 相关阅读:
    day04--项目前端相关基础知识(二)
    day03--项目前端相关基础知识
    day02--环境搭建与讲师管理接口开发
    module3_PC端静态页面项目初始化
    module3_03_写静态页面需要注意的点
    module3_02_静态页面项目初始化
    module3_01_版心与页面排版布局
    学习上遇到的坑
    flex布局相关
    background中url后面按的数意思
  • 原文地址:https://www.cnblogs.com/xingxia/p/git_use.html
Copyright © 2020-2023  润新知