git命令行的使用

一.Git的安装与简单配置:https://blog.csdn.net/qq_23341529/article/details/79331519

 

二、Git的使用

1、初始化一个新的git仓库

     a、创建文件夹

         方法一:点击鼠标右键,新建

  方法二:使用git新建:输入命令$ mkdir '文件名'

 

     b、在文件内初始化git(创建git仓库)

         方法一:直接输入$ cd 文件名

  方法二:鼠标右击要初始化的文件选择Git Bash Here 然后输入$ git init命令

 

 2、向仓库中添加文件 

         方法一:打开编译器新建indext.html文件

  方法二:用git命令。$ touch '文件名',然后把文件通过$ git add '文件名'添加到暂存区,最后提交操作$git commit -m '提交说明'

 

3、修改仓库文件

      方法一:直接在编译器中进行修改,然后进行提交操作

方法二:使用git命令。$ 修改内容 '文件名',然后进行提交操作

 

4、删除仓库文件

方法一:直接在编译器中进行删除

方法二:使用git命令删除:$git rm '文件名',然后提交操作

 

5、向仓库中添加文件流程

($git status查看状态) git仓库-----$git add '文件名'-----暂存区----$git commit -m '提交说明'-----工作区

 

6、将本地仓库同步到git远程仓库中:git push

 

三. git如何上传所有的新文件

 

步骤:进入项目文件夹,在其中使用git bash

 

1.使用git clone命令将新建的git 项目信息下载到本地

 

git clone  git address

 

2.进入git项目的本地文件夹,将自己的项目复制到这个git 文件夹,查看状态,提交所有的新文件

git status 

git add -A

git commit -a -m"first commit"

3.上传更新到git 版本库

git push

 

 

 

注:git add上传本地项目所有变化的命令三种有 git add -A、git add -u、git add .

 

git add -A  提交所有变化

git add -u  提交被修改(modified)和被删除(deleted)文件,不包括新文件(new)

git add .  提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件

 

四.提交文件到github的两种方法

简要步骤如下:

 

1.登陆github,创建git仓库。记此git仓库的地址为[github_repository_url],例如git仓库的地址:https://github.com/galian123/nodejs_http_server

 

2.在本地的工程目录执行git init,此工程目录是要提交到github的。git init是将本地的工程目录作为本地的git仓库。 

注:下面的git命令都是在此工程目录中执行的

 

3.执行git add .,将本地的工程目录(包括子文件)都添加到本地的git仓库

 

4.执行git commit -m "write some comment",将本地的工程提交到本地的git仓库

 

5.执行git remote add origin [github_repository_url],将本地仓库与github上的仓库关联起来。 

可以通过git remote -v查看github上的仓库地址。

 

6.执行git pull origin master同步github仓库和本地仓库

 

7.执行git push origin master将本地工程提交到github

 

 

tp5的cli模式

第一步,配置commond.php文件,目录在application/command.php

 

 

return [

    'app\home\command\Test',

];

 

第二步:建立命令类文件,新疆application/home/command/Test.php

   

namespace app\home\command;

 

use think\console\Command;

use think\console\Input;

use think\console\Output;

 

class Test extends Command

{

    protected function configure()

    {

        $this->setName('test')->setDescription('Here is the remark ');

    }

 

    protected function execute(Input $input, Output $output)

    {

        $output->writeln("TestCommand:");

    }

}

 

这个文件定义了一个叫test的命令,备注为here is the remark

执行命令会输出TestCommand

 

第三步,测试-命令帮助-命令行下运行

php think

 

Think Console version 0.1

 

Usage:

  command [options] [arguments]

 

Options:

  -h, --help            Display this help message

  -V, --version         Display this console version

  -q, --quiet           Do not output any message

      --ansi            Force ANSI output

      --no-ansi         Disable ANSI output

  -n, --no-interaction  Do not ask any interactive question

  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

 

Available commands:

  build              Build Application Dirs

  clear              Clear runtime file

  help               Displays help for a command

  list               Lists commands

  test               Here is the remark 

 make

  make:controller    Create a new resource controller class

  make:model         Create a new model class

 optimize

  optimize:autoload  Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.

  optimize:config    Build config and common file cache.

  optimize:route     Build route cache.

  optimize:schema    Build database schema cache.

 

第四部,运行test命令

 php think test

 

输出testCommang;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值