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

    ---恢复内容开始---

    1.学习 git 命令

    $ git help //查看帮助

    $ git help init //一个命令的使用方法

    2初始化一个本地仓库

    命令 :$ git init

     

    3.配置仓库

      配置用户名和邮箱

    $ git config user.name manager

    $ git config user.email manager@gmail.com

    4 如果要一次性配置完成可以使用一下命令

    $ git config --global user.name manager

    $ git config --global user.email manager@gmail.com

    * 以上两个命令会将用户信息保存在用户目录下的 .gitconfig 文件中

    5  查看当前所有配置

    $ git config -l

    6.常用命令

    # 查看当前代码库状态

    $ git status

    # 将文件添加到代码库

    $ git add main.c

    # 将修改提交到代码库

    $ git commit -m "添加了main.c"

    # 将当前文件夹下的所有新建或修改的文件一次性添加到代码库

    $ git add .

    * 注意 使用git时,每一次修改都需要添加再提交,这一点是与svn不一样的

    # 查看所有版本库日志

    $ git log

    # 查看指定文件的版本库日志

    $ git log 文件名

    7 版本号

    # 回到当前版本,放弃所有没有提交的修改

    $ git reset --hard HEAD

    # 回到上一个版本

    $ git reset --hard HEAD^

    # 回到之前第3个修订版本

    $ git reset --hard HEAD~3

    # 回到指定版本号的版本

    $ git reset --hard e695b67

    # 查看分支引用记录

    $ git reflog

    8.vim 编辑器的简单使用

    保存文件并退出vim : wq 

    强制退出不保存: q!

    9.git 设置别名

    $ git config alias.st "status"

    10.--global的作用

    可以进行全局配置,所有的版本库共享此配置

    $ git config --global alias.st "status"

     

    查看全局配置(桌面前往->个人->.gitconfig

    ** 个人电脑上建议使用全局配置**

    Git 团队开发

     

    1. 搭建本地共享库

    cd 进入本地文件夹

    执行命令: git init —-bare

    2.初始化项目到本地共享库

    命令: git clone 本地代码仓库地址

    3.创建项目

    touch person.h

    git add .  /把创建的文件添加到暂存区   

    git commit -m “创建person.h”//提交到 master 分支

    git push    //push 到共享库

    git pull    //代码修改同步

     

    4修改文件同步

            命令:
                git add .
                git commit -m “注释”
                git push
                git pull
    5删除文件同步
            命令:
                git rm filename
                git commit -m “注释”
                git push      
                git pull
    6冲突解决

            命令:
                git pull

    7忽略文件
            命令:
                touch .gitignore  
                open .gitignore   加入忽略文件名
                git add .    
                git commit -m “注释”

     

    ---恢复内容结束---

  • 相关阅读:
    BeforeFieldInit解析(zz)
    自定义控件
    How to make Office VBA code interact with a VSTO applicationlevel addin
    总结
    IL汇编语言程序设计目录
    zz如何精简用户界面
    volatile关键字的作用(zz)
    外企面试基本涵盖了所有问题(拿得别人的,很有用)
    Excel 2007 There was a problem sending the command to the program
    数据库技巧
  • 原文地址:https://www.cnblogs.com/ningmengcao-ios/p/5768737.html
Copyright © 2011-2022 走看看