<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title> 尹成的技术专栏</title>
    <description></description>
    <link>https://clendy.github.io/</link>
    <atom:link href="https://clendy.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sun, 26 Apr 2020 14:41:27 +0000</pubDate>
    <lastBuildDate>Sun, 26 Apr 2020 14:41:27 +0000</lastBuildDate>
    <generator>Jekyll v3.8.5</generator>
    
      <item>
        <title>Android-电池省点优化</title>
        <description>&lt;!-- MarkdownTOC --&gt;

&lt;!-- /MarkdownTOC --&gt;

&lt;h1 id=&quot;电池省点优化doze和standby模式&quot;&gt;电池省点优化（Doze和Standby模式）&lt;/h1&gt;

&lt;blockquote&gt;
  从Android6.0开始,系统提供了两种省电功能(延长电池寿命和使用时间):Doze和App Standby Doze和App Standby模式会延缓CPU和网络活动实现节能;
&lt;/blockquote&gt;

&lt;h2 id=&quot;doze模式&quot;&gt;Doze模式&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;进入Doze模式，在手机未充电,完全静止且熄屏一段时间后,Android系统会自动进入Doze模式；&lt;/li&gt;
  &lt;li&gt;Doze模式效果
    &lt;ol&gt;
      &lt;li&gt;网络访问被挂起；&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Wake Locks&lt;/code&gt;被无视；&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AlarmManager&lt;/code&gt;被推迟到下一个&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;maintenance window&lt;/code&gt;窗口,
 除非使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AlarmManager&lt;/code&gt;新方法: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setAndAllowWhileIdle(),setExactAndAllowWhileIdle(),setAlarmClock()&lt;/code&gt;;&lt;/li&gt;
      &lt;li&gt;WiFi扫描被停止;&lt;/li&gt;
      &lt;li&gt;SyncAdapter同步工作被停止;&lt;/li&gt;
      &lt;li&gt;JobScheduler定时任务被停止：&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;退出Doze模式
    &lt;ol&gt;
      &lt;li&gt;手机充电&lt;/li&gt;
      &lt;li&gt;手机移动&lt;/li&gt;
      &lt;li&gt;手机屏幕打开&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;app-standby模式&quot;&gt;App Standby模式&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;
    进入App Standby模式
 长时间未被用户使用的App,将进入App Standby状态(被标志为空闲状态)
  &lt;/li&gt;
  &lt;li&gt;退出App Standby模式
    &lt;ol&gt;
      &lt;li&gt;用户主动启动该App&lt;/li&gt;
      &lt;li&gt;该App有前台进程(前台activity/前台service),被其它前台进程启动&lt;/li&gt;
      &lt;li&gt;该App在锁屏或通知栏有可见的Notification&lt;/li&gt;
      &lt;li&gt;Android设备充电时,会将所有Standby状态的App释放,处理挂起任务&lt;/li&gt;
      &lt;li&gt;如果App空闲时间很长,系统将允许App一天一次访问网络&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;App Standby和Doze区别
App Standby不需要屏幕关闭,App进入后台一段时间,网络也会受到限制
Doze模式需要屏幕关闭(通常晚上睡觉或长时间屏幕关闭才会进入)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;阻止电池优化白名单&quot;&gt;阻止电池优化(白名单)&lt;/h2&gt;
Android6.0及更高版本提供电池优化白名单,App加入白名单可逃脱Doze和App Standby限制,
处于白名单中的App也会受到一定限制: Jobs和Syncs以及常规Alarms也会被推迟；

用户手动设置App进入白名单: &lt;strong&gt;设置&lt;/strong&gt;&amp;gt;&lt;strong&gt;电池&lt;/strong&gt;&amp;gt;&lt;strong&gt;电池优化白名单&lt;/strong&gt;

App检测是否在白名单: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PowerManager.isIgnoringBatteryOptimizations()&lt;/code&gt;

App请求加入白名单:
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.M) {
	PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
	if (pm != null &amp;amp;&amp;amp; !pm.isIgnoringBatteryOptimizations(getPackageName())) {
		//1.进入系统电池优化设置界面,把当前APP加入白名单
		//startActivity(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS));
		
		//2.弹出系统对话框,把当前APP加入白名单(无需进入设置界面)
		//在manifest添加权限 &amp;lt;uses-permission android:name=&quot;android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS&quot;/&amp;gt;
		Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
		intent.setData(Uri.parse(&quot;package:&quot; + getPackageName()));
		startActivity(intent);
	}
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;alarmmanager定时闹钟失效&quot;&gt;AlarmManager定时闹钟失效&lt;/h1&gt;

&lt;ol&gt;
  &lt;li&gt;App被Kill后，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AlarmManager&lt;/code&gt;失效(只有App进程在运行时，才会收到系统定时&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AlarmManager&lt;/code&gt;通知)
 添加守护进程,相互监听重启; 提醒用户加入锁屏清理白名单&lt;/li&gt;
  &lt;li&gt;手机重启，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AlarmManager&lt;/code&gt;任务失效
 监听重启广播,重新设置定时闹钟&lt;/li&gt;
  &lt;li&gt;从Android4.4(API19)开始，AlarmManager机制修改,set(),setRepeating()定时不再精确，甚至setRepeating只生效一次(不会重复)
 新增精确定时方法:  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setExact()&lt;/code&gt;，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setWindow()&lt;/code&gt;，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setAlarmClock()&lt;/code&gt;；&lt;/li&gt;
  &lt;li&gt;从Android6.0(API23)开始,进入Doze模式(省电优化),&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AlarmManager&lt;/code&gt;被延缓
 新增精确定时方法: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setAndAllowWhileIdle()&lt;/code&gt;,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setExactAndAllowWhileIdle()&lt;/code&gt;；&lt;/li&gt;
&lt;/ol&gt;

从Android4.4(API19)开始,新增精准定时方法都是一次性闹钟,没有重复定时的方法,
所以当需要重复周期闹钟,只能在下一次唤醒时重新设置定时,间接实现重复闹钟。

精确定时一次Demo如下：
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;void setWakeAtTime(Context cxt, int delay) {
	PendingIntent pi = PendingIntent.getService(cxt,0,new Intent(cxt, xxService.class),PendingIntent.FLAG_UPDATE_CURRENT); 
    AlarmManager alarm = (AlarmManager) cxt.getSystemService(Context.ALARM_SERVICE);
	if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.M) //Android 6，针对省电优化
		alarm.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, pi);
	else if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.KITKAT) //Android 4.4，针对set不准确
		alarm.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, pi);
	else
		alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, pi);   
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Fri, 01 Feb 2019 00:00:00 +0000</pubDate>
        <link>https://clendy.github.io/2019/02/01/Android-%E7%94%B5%E6%B1%A0%E7%9C%81%E7%82%B9%E4%BC%98%E5%8C%96/</link>
        <guid isPermaLink="true">https://clendy.github.io/2019/02/01/Android-%E7%94%B5%E6%B1%A0%E7%9C%81%E7%82%B9%E4%BC%98%E5%8C%96/</guid>
        
        <category>Android</category>
        
        
      </item>
    
      <item>
        <title>Kotlin Coroutines</title>
        <description>&lt;!-- MarkdownTOC --&gt;

&lt;!-- /MarkdownTOC --&gt;

&lt;h1 id=&quot;kotlin协程和作用&quot;&gt;Kotlin协程和作用&lt;/h1&gt;

&lt;blockquote&gt;
  一些耗时操作(网络IO、文件IO、CPU/GPU密集型任务)会阻塞线程直到操作完成，
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Kotlin&lt;/code&gt;的协程提供一种避免阻塞且更廉价可控的操作: 协程挂起(coroutine suspension),
协程将复杂异步操作放入底层库中,程序逻辑可顺序表达,以此简化异步编程，
该底层库将用户代码包装为回调/订阅事件,在不同线程(甚至不同机器)调度执行!
&lt;/blockquote&gt;

&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Kotlin&lt;/code&gt;的协程还能实现其它语言的异步机制(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;asynchronous mechanisms&lt;/code&gt;),
例如源于C#和ECMAScript(js)的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;async/await&lt;/code&gt;机制，
源于Go的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;channel/select&lt;/code&gt;机制,源于C#和Python的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;generators/yield&lt;/code&gt;机制。

&lt;h1 id=&quot;线程阻塞和协程挂起的区别blocking-vs-suspending&quot;&gt;线程阻塞和协程挂起的区别(Blocking VS Suspending)&lt;/h1&gt;
协程是通过编译技术实现(不需要虚拟机VM/操作系统OS的支持),通过插入相关代码来生效！
与之相反,线程/进程是需要虚拟机VM/操作系统OS的支持,通过调度CPU执行生效!

线程阻塞的代价昂贵,
尤其在高负载时的可用线程很少,阻塞线程会导致一些重要任务缺少可用线程而被延迟!

协程挂起几乎无代价,无需上下文切换或涉及OS,
最重要的是,协程挂起可由用户控制:可决定挂起时发生什么,并根据需求优化/记录日志/拦截!

另一个不同之处是,协程不能在随机指令中挂起,只能在挂起点挂起(调用标记函数)!

&lt;h1 id=&quot;挂起函数suspending-functions&quot;&gt;挂起函数(Suspending functions)&lt;/h1&gt;

当调用[suspend修饰的函数]时会发生协程挂起：
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    suspend fun doSomething(foo: Foo): Bar {           
    }        
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
该函数称为挂起函数,调用它们可能挂起协程(如果调用结果已经可用,协程库可决定不挂起)
挂起函数能像普通函数获取参数和返回值,但只能在协程/挂起函数中被调用!

启动协程,至少要有一个挂起函数,通常是匿名的(即挂起lambda表达式),一个简化的async函数(源自kotlinx.coroutines库)：

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    //async函数是一个普通函数(不是挂起函数)
    //block参数有suspend修饰,是一个匿名的挂起函数(即挂起lambda表达式)
    fun &amp;lt;T&amp;gt; async(block: suspend () -&amp;gt; T)

    async {
        //doSomething在挂起函数(挂起lambda)中被调用
        doSomething(foo)
        ...
    }

    async {
        ...
        //await()是挂起函数,该函数挂起一个协程,直到执行完成返回结果
        val result = computation.await()  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

挂起函数不能在普通函数中被调用：
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    fun main(args: Array&amp;lt;String&amp;gt;) {
        doSomething() //错误: 挂起函数不能在非协程中被调用
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
挂起函数可以是虚拟的,当覆盖它们时,必须指定suspend修饰符：
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    interface Base {
        suspend fun foo()
    }

    class Derived: Base {
        override suspend fun foo() {                
        }
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;协程内部机制原理inner-workings&quot;&gt;协程内部机制原理(inner workings)&lt;/h1&gt;
粗略地认识协程机制原理是相当重要的!

协程是通过编译技术实现(不需要虚拟机VM/操作系统OS的支持),通过插入相关代码来生效！
与之相反,线程/进程是需要虚拟机VM/操作系统OS的支持,通过调度CPU执行生效!

基本上,每个挂起函数都转换为状态机,对应于挂起调用;
在挂起协程前,下一状态和相关局部变量等被存储在编译器生成的类字段中;
在恢复协程时,状态机从下一状态进行并恢复局部变量！

一个挂起的协程可作为保存挂起状态和局部变量的对象,对象类型是Continuation,
在底层,挂起函数有一个Continuation类型的额外参数

关于协程工作原理的更多细节可查看:
&lt;a href=&quot;https://github.com/Kotlin/kotlin-coroutines/blob/master/kotlin-coroutines-informal.md&quot;&gt;https://github.com/Kotlin/kotlin-coroutines/blob/master/kotlin-coroutines-informal.md&lt;/a&gt;

</description>
        <pubDate>Sun, 07 Jan 2018 00:00:00 +0000</pubDate>
        <link>https://clendy.github.io/2018/01/07/Kotlin-Coroutines/</link>
        <guid isPermaLink="true">https://clendy.github.io/2018/01/07/Kotlin-Coroutines/</guid>
        
        <category>Kotlin</category>
        
        
      </item>
    
      <item>
        <title>Markdown Beginner</title>
        <description>&lt;!-- MarkdownTOC --&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#tools&quot;&gt;Tools&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#markdown-syntax&quot;&gt;Markdown: Syntax&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#%E7%9B%AE%E5%BD%95&quot;&gt;目录&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E6%A0%87%E9%A2%98&quot;&gt;标题&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E5%88%97%E8%A1%A8&quot;&gt;列表&lt;/a&gt;
        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#%E6%97%A0%E5%BA%8F&quot;&gt;无序&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#%E6%9C%89%E5%BA%8F&quot;&gt;有序&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#%E5%B5%8C%E5%A5%97%E5%88%97%E8%A1%A8&quot;&gt;嵌套列表&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E5%BC%95%E7%94%A8&quot;&gt;引用&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E5%9B%BE%E7%89%87&quot;&gt;图片&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E9%93%BE%E6%8E%A5&quot;&gt;链接&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E7%B4%A2%E5%BC%95%E9%93%BE%E6%8E%A5&quot;&gt;索引链接&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E6%9C%AC%E8%BA%AB%E5%B0%B1%E6%98%AF%E9%93%BE%E6%8E%A5&quot;&gt;本身就是链接&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E5%88%86%E5%89%B2%E7%BA%BF&quot;&gt;分割线&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E8%A1%A8%E6%A0%BC&quot;&gt;表格&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E4%BB%A3%E7%A0%81%E5%9D%97&quot;&gt;代码块&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#%E8%BD%AC%E4%B9%89&quot;&gt;转义&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#others&quot;&gt;Others&lt;/a&gt;
        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#%E7%B2%97%E4%BD%93&quot;&gt;粗体&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#%E6%96%9C%E4%BD%93&quot;&gt;斜体&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#%E5%AD%97%E4%BD%93-%E5%AD%97%E5%8F%B7-%E5%92%8C%E9%A2%9C%E8%89%B2&quot;&gt;字体, 字号, 和颜色&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#reference&quot;&gt;Reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- /MarkdownTOC --&gt;

&lt;h1 id=&quot;前言&quot;&gt;前言&lt;/h1&gt;
阶段性总结有利于精确自己的目标, 以及为后续的想法开辟空间.

因此开始有必要整理记录.

但是因为没必要像写paper那样规范使用latex, 因此就选择了Markdown.

&lt;h2 id=&quot;tools&quot;&gt;Tools&lt;/h2&gt;
Windows - &lt;a href=&quot;http://www.markdownpad.com/&quot;&gt;MarkdownPad&lt;/a&gt;

Github Pages - (If you have one)

&lt;h1 id=&quot;markdown-syntax&quot;&gt;Markdown: Syntax&lt;/h1&gt;
&lt;h2 id=&quot;目录&quot;&gt;目录&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[TOC]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

由于github不支持显示TOC, 因此需要先用&lt;strong&gt;markdown-toc&lt;/strong&gt;&lt;a href=&quot;[markdown toc](https://github.com/houbb/markdown-toc)&quot;&gt;4&lt;/a&gt;进行预处理
也可以使用sublime里的&lt;strong&gt;markdown-toc&lt;/strong&gt;&lt;a href=&quot;[sublime with markdown-toc](https://www.cnblogs.com/Sinte-Beuve/p/5148108.html)&quot;&gt;5&lt;/a&gt;插件.

&lt;h2 id=&quot;标题&quot;&gt;标题&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# content
## content
### content
......
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

一共可以设置六级标题

&lt;h2 id=&quot;列表&quot;&gt;列表&lt;/h2&gt;
&lt;h3 id=&quot;无序&quot;&gt;无序&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;* 1
* 2
* 3 * 1 * 2 * 3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;有序&quot;&gt;有序&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;1. 1
2. 2
3. 3 1. 1 2. 2 3. 3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;嵌套列表&quot;&gt;嵌套列表&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;- AAA
  + A
    - a
      1. contentA
      2. contentB
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;AAA
    &lt;ul&gt;
      &lt;li&gt;A
        &lt;ul&gt;
          &lt;li&gt;a
            &lt;ol&gt;
              &lt;li&gt;contentA&lt;/li&gt;
              &lt;li&gt;contentB&lt;/li&gt;
            &lt;/ol&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;引用&quot;&gt;引用&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; contentA
  &amp;gt;&amp;gt; contentB
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  contentA
  &lt;blockquote&gt;
    contentB
  &lt;/blockquote&gt;
&lt;/blockquote&gt;

之后的文本内容需要插入空行

&lt;h2 id=&quot;图片&quot;&gt;图片&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;！[icon](link to the picture)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;链接&quot;&gt;链接&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[content](link to the content)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;索引链接&quot;&gt;索引链接&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[content][1]
[1]:Url [content][1] [1]:Url
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;本身就是链接&quot;&gt;本身就是链接&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;url&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;a href=&quot;https://xinyao1994.github.io/&quot;&gt;https://xinyao1994.github.io/&lt;/a&gt;

&lt;h2 id=&quot;分割线&quot;&gt;分割线&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;***
---
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;表格&quot;&gt;表格&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Tables&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Are&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Cool&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;col 3 is&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;right-aligned&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;$1600&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;col 2 is&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;centered&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;$12&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;zebra stripes&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;are neat&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;$1&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;代码块&quot;&gt;代码块&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;``` [python]
@requires_authorization
def add(a, b): # add a and b
    return a+b
class TA:
```
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;language-[python]&quot;&gt;@requires_authorization
def add(a, b): # add a and b
	return a+b
class TA:
&lt;/code&gt;&lt;/pre&gt;

or 每行文字前加4个空格或者1个Tab

&lt;h2 id=&quot;转义&quot;&gt;转义&lt;/h2&gt;

&lt;h2 id=&quot;others&quot;&gt;Others&lt;/h2&gt;
&lt;h3 id=&quot;粗体&quot;&gt;粗体&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;**content** **content**

__content__ __content__
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;斜体&quot;&gt;斜体&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;*content* *content*

_content_ _content_
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;字体-字号-和颜色&quot;&gt;字体, 字号, 和颜色&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;font face=&quot;黑体&quot;&amp;gt;我是黑体字&amp;lt;/font&amp;gt;
&amp;lt;font face=&quot;微软雅黑&quot;&amp;gt;我是微软雅黑&amp;lt;/font&amp;gt;
&amp;lt;font face=&quot;Verdana&quot;&amp;gt;I like Verdana format&amp;lt;/font&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;font face=&quot;黑体&quot;&gt;我是黑体字&lt;/font&gt;

&lt;font face=&quot;微软雅黑&quot;&gt;我是微软雅黑&lt;/font&gt;

&lt;font face=&quot;Verdana&quot;&gt;I like Verdana format&lt;/font&gt;

&lt;h1 id=&quot;reference&quot;&gt;Reference&lt;/h1&gt;

</description>
        <pubDate>Mon, 25 Sep 2017 00:00:00 +0000</pubDate>
        <link>https://clendy.github.io/2017/09/25/Markdown-Beginner-copy/</link>
        <guid isPermaLink="true">https://clendy.github.io/2017/09/25/Markdown-Beginner-copy/</guid>
        
        <category>Markdown</category>
        
        
      </item>
    
      <item>
        <title>Git Beginner</title>
        <description>&lt;!-- MarkdownTOC --&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#what-is-a-git&quot;&gt;What is a git&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#preparation&quot;&gt;Preparation&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#history&quot;&gt;History&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#install&quot;&gt;Install&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#configuration&quot;&gt;configuration&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#begin&quot;&gt;Begin&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#init-the-git&quot;&gt;init the git&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#stream&quot;&gt;stream&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#file-operations&quot;&gt;File Operations&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#add-git-status-to-check&quot;&gt;Add (git status to check)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#removegit-status-to-check&quot;&gt;Remove(git status to check)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#renamegit-status-to-check&quot;&gt;Rename(git status to check)&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#rollback&quot;&gt;Rollback&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#git-diff-to-check-to-change&quot;&gt;git diff to check to change&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#git reset&quot;&gt;Warning&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#gitignore&quot;&gt;.gitignore&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#gitkeep&quot;&gt;.gitkeep&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#other-options&quot;&gt;Other options&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#branch&quot;&gt;Branch&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#branch-is-needed-cheap-try&quot;&gt;branch is needed, cheap, try&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#operations&quot;&gt;operations&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#merge&quot;&gt;Merge&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#stash&quot;&gt;stash&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#remote-link-to-the-github-or-others&quot;&gt;Remote (link to the github or others)&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#set-up-a-github-account&quot;&gt;Set up a github account&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#password-caching&quot;&gt;password caching&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;!-- /MarkdownTOC --&gt;

&lt;a id=&quot;what-is-a-git&quot;&gt;&lt;/a&gt;
&lt;h2 id=&quot;what-is-a-git&quot;&gt;What is a git&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; git 帮助我们进行代码的版本控制，我于2015/10/1花费一天时间学习一个关于git的视频,然后再参考几篇博客,将git的使用方法全部弄清楚。let's begin!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;a id=&quot;preparation&quot;&gt;&lt;/a&gt;
##Preparation

&lt;a id=&quot;history&quot;&gt;&lt;/a&gt;
&lt;h3 id=&quot;history&quot;&gt;History&lt;/h3&gt;
&lt;ol&gt;
  &lt;li&gt;*SCCS Source Code Control System *
    &lt;ul&gt;
      &lt;li&gt;1972， closed source, free with Unix&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;*RCS Revision Control System *
    &lt;ul&gt;
      &lt;li&gt;1982， open source.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;*CVS Concurrent Versions System *
    &lt;ul&gt;
      &lt;li&gt;1986 - 1990, open source&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;*SVN *
    &lt;ul&gt;
      &lt;li&gt;2000, open source&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;em&gt;BitKeeper SCM&lt;/em&gt;
    &lt;ul&gt;
      &lt;li&gt;distributed version&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;*GIT *
    &lt;ul&gt;
      &lt;li&gt;github come out
&lt;a id=&quot;install&quot;&gt;&lt;/a&gt;
        &lt;h3 id=&quot;install&quot;&gt;Install&lt;/h3&gt;
        &lt;blockquote&gt;
          参考官网的安装方法    —— &lt;a href=&quot;https://git-scm.com&quot; target=&quot;_blank&quot;&gt; [git web]&lt;/a&gt;
        &lt;/blockquote&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;download the tar.gz or some package[your linux]&lt;/li&gt;
  &lt;li&gt;tar zxvf *.tar.gz&lt;/li&gt;
  &lt;li&gt;/configure&lt;/li&gt;
  &lt;li&gt;make &amp;amp;&amp;amp; make install&lt;/li&gt;
  &lt;li&gt;finish.
or you can try:
    &lt;ul&gt;
      &lt;li&gt;apt-get install git&lt;/li&gt;
      &lt;li&gt;yum install -y git&lt;/li&gt;
      &lt;li&gt;pacman -S git
&lt;a id=&quot;configuration&quot;&gt;&lt;/a&gt;
###configuration&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;git config –global user.name [your name]&lt;/li&gt;
  &lt;li&gt;git config –global user.email [your email]&lt;/li&gt;
  &lt;li&gt;git config –global core.editor “vim”&lt;/li&gt;
  &lt;li&gt;git config –global color.ui true&lt;/li&gt;
  &lt;li&gt;use bash config
    &lt;ul&gt;
      &lt;li&gt;wget https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
       * ls
       * mv git-completion.bash ~/.git-completion.bash
       * add to .bashrc that if exist this bash, source it.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;help 
&lt;a id=&quot;begin&quot;&gt;&lt;/a&gt;
    &lt;h2 id=&quot;begin&quot;&gt;Begin&lt;/h2&gt;
    &lt;a id=&quot;init-the-git&quot;&gt;&lt;/a&gt;
    &lt;h3 id=&quot;init-the-git&quot;&gt;init the git&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;mkdir dir1&lt;/li&gt;
  &lt;li&gt;cd dir1&lt;/li&gt;
  &lt;li&gt;git init&lt;/li&gt;
  &lt;li&gt;add one file (make change)&lt;/li&gt;
  &lt;li&gt;git add . (add change)&lt;/li&gt;
  &lt;li&gt;git commit -m “some word” (commit change)&lt;/li&gt;
  &lt;li&gt;git log -n/ –since/ –until/ –grep
&lt;a id=&quot;stream&quot;&gt;&lt;/a&gt;
    &lt;h3 id=&quot;stream&quot;&gt;stream&lt;/h3&gt;
    working -add file- staging index -commit- repositiry
  &lt;/li&gt;
&lt;/ol&gt;

&lt;a id=&quot;file-operations&quot;&gt;&lt;/a&gt;
&lt;h2 id=&quot;file-operations&quot;&gt;File Operations&lt;/h2&gt;
&lt;a id=&quot;add-git-status-to-check&quot;&gt;&lt;/a&gt;
&lt;h3 id=&quot;add-git-status-to-check&quot;&gt;Add (git status to check)&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;git add .&lt;/li&gt;
  &lt;li&gt;git commit -m “”&lt;/li&gt;
  &lt;li&gt;git diff&lt;/li&gt;
  &lt;li&gt;git commit -ma “”
&lt;a id=&quot;removegit-status-to-check&quot;&gt;&lt;/a&gt;
    &lt;h3 id=&quot;removegit-status-to-check&quot;&gt;Remove(git status to check)&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;git rm filename&lt;/li&gt;
  &lt;li&gt;git commit -m “”
&lt;a id=&quot;renamegit-status-to-check&quot;&gt;&lt;/a&gt;
    &lt;h3 id=&quot;renamegit-status-to-check&quot;&gt;Rename(git status to check)&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;git add file&lt;/li&gt;
  &lt;li&gt;git rm file&lt;/li&gt;
  &lt;li&gt;git commit -m “”&lt;/li&gt;
  &lt;li&gt;or you can use git mv file1 file2
&lt;a id=&quot;rollback&quot;&gt;&lt;/a&gt;
    &lt;h2 id=&quot;rollback&quot;&gt;Rollback&lt;/h2&gt;
    &lt;a id=&quot;git-diff-to-check-to-change&quot;&gt;&lt;/a&gt;
    &lt;h3 id=&quot;git-diff-to-check-to-change&quot;&gt;git diff to check to change&lt;/h3&gt;
    &lt;ol&gt;
      &lt;li&gt;git checkout – file(before add)
  it can return the status of the workspace.&lt;/li&gt;
      &lt;li&gt;git reset HEAD file (after add)&lt;/li&gt;
    &lt;/ol&gt;
    &lt;ul&gt;
      &lt;li&gt;unstage the file -&amp;gt; before add&lt;/li&gt;
      &lt;li&gt;git checkout – file
        &lt;ol&gt;
          &lt;li&gt;git (after commit)&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
      &lt;li&gt;find the Hash value of commit&lt;/li&gt;
      &lt;li&gt;git comment –amend append to the same commit&lt;/li&gt;
      &lt;li&gt;git diff –staged&lt;/li&gt;
      &lt;li&gt;return the commit status
        &lt;blockquote&gt;
          git checkout [commit hash] – file
        &lt;/blockquote&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;a id=&quot;git reset&quot;&gt;&lt;/a&gt;
&lt;h3 id=&quot;warning-git-reset&quot;&gt;Warning [git reset]&lt;/h3&gt;
&lt;ol&gt;
  &lt;li&gt;–soft not change staging index &amp;amp; workspace&lt;/li&gt;
  &lt;li&gt;–mixed(default) change staging &amp;amp; not workspace&lt;/li&gt;
  &lt;li&gt;–hard change staging &amp;amp; change workspace
    &lt;blockquote&gt;
      usage : git reset –soft [commit hash]
git reset HEAD file
-n try to do -f force to do
&lt;a id=&quot;gitignore&quot;&gt;&lt;/a&gt;
      &lt;h3 id=&quot;gitignore&quot;&gt;.gitignore&lt;/h3&gt;
      it can help us to ignore some file or dir
reference :
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;help.github.com/articles/ignoring-files&lt;/li&gt;
  &lt;li&gt;github.com/github/gitignore
git config –global core.excludesfile pathtofile
    &lt;ul&gt;
      &lt;li&gt;git rm –cached file 
&lt;a id=&quot;gitkeep&quot;&gt;&lt;/a&gt;
        &lt;h3 id=&quot;gitkeep&quot;&gt;.gitkeep&lt;/h3&gt;
        git log –oneline/ –graph/ –all/ –decorate
&lt;a id=&quot;other-options&quot;&gt;&lt;/a&gt;
        &lt;h3 id=&quot;other-options&quot;&gt;Other options&lt;/h3&gt;
      &lt;/li&gt;
      &lt;li&gt;git show [hash]&lt;/li&gt;
      &lt;li&gt;git diff [hash] &amp;amp; git diff [hash1]..[hash2]
&lt;a id=&quot;branch&quot;&gt;&lt;/a&gt;
        &lt;h2 id=&quot;branch&quot;&gt;Branch&lt;/h2&gt;
        &lt;a id=&quot;branch-is-needed-cheap-try&quot;&gt;&lt;/a&gt;
        &lt;h3 id=&quot;branch-is-needed-cheap-try&quot;&gt;branch is needed, cheap, try&lt;/h3&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;try new ideas&lt;/li&gt;
  &lt;li&gt;isolate the workspace&lt;/li&gt;
  &lt;li&gt;fast context switching
&lt;a id=&quot;operations&quot;&gt;&lt;/a&gt;
    &lt;h3 id=&quot;operations&quot;&gt;operations&lt;/h3&gt;
    &lt;blockquote&gt;
      &lt;ul&gt;
        &lt;li&gt;git branch&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;create&lt;/strong&gt; -&amp;gt; git branch new_branch_name&lt;/li&gt;
        &lt;li&gt;&lt;strong&gt;switch&lt;/strong&gt; -&amp;gt; git checkout branch_name&lt;/li&gt;
        &lt;li&gt;git checkout -b new_branch_name&lt;/li&gt;
        &lt;li&gt;git diff [branch1]..[branch2] (use –color-words)&lt;/li&gt;
        &lt;li&gt;git branch –merged&lt;/li&gt;
        &lt;li&gt;git branch -m old_name new_name (–move)&lt;/li&gt;
        &lt;li&gt;git barnch -d(–delete) name (-D to delete a non-empty branch)&lt;/li&gt;
        &lt;li&gt;prompt
          &lt;ol&gt;
            &lt;li&gt;export PS1=’$(__git_ps1 “(%s)”) &amp;gt; ‘&lt;/li&gt;
            &lt;li&gt;export PS1=’\W$(__git_ps1 “(%s)”) &amp;gt; ‘&lt;/li&gt;
            &lt;li&gt;export PS1=$PS1’$(__git_ps1 “(%s)”) &amp;gt; ‘ (it’s cool !)&lt;/li&gt;
          &lt;/ol&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ol&gt;

Attantion: barnch is a stack mode, current branch can’t be delete
&lt;a id=&quot;merge&quot;&gt;&lt;/a&gt;
&lt;h3 id=&quot;merge&quot;&gt;Merge&lt;/h3&gt;
&lt;blockquote&gt;
  &lt;ul&gt;
    &lt;li&gt;git merge exist_branch&lt;/li&gt;
    &lt;li&gt;git branch –merged&lt;/li&gt;
    &lt;li&gt;conflict
      &lt;ul&gt;
        &lt;li&gt;
          &lt;ol&gt;
            &lt;li&gt;change by yourselt&lt;/li&gt;
          &lt;/ol&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;ol&gt;
            &lt;li&gt;git log –graph –oneline –all –decorate&lt;/li&gt;
          &lt;/ol&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;ol&gt;
            &lt;li&gt;git mergetool –tool=&lt;/li&gt;
          &lt;/ol&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

Attention:
&lt;ul&gt;
  &lt;li&gt;keep lines short&lt;/li&gt;
  &lt;li&gt;commits small focused&lt;/li&gt;
  &lt;li&gt;merge often
&lt;a id=&quot;stash&quot;&gt;&lt;/a&gt;
    &lt;h3 id=&quot;stash&quot;&gt;stash&lt;/h3&gt;
    &lt;ol&gt;
      &lt;li&gt;git stash save “changed mission …”&lt;/li&gt;
      &lt;li&gt;git stash list&lt;/li&gt;
      &lt;li&gt;git stash show stash@{0}  (you may use -p option)&lt;/li&gt;
      &lt;li&gt;git stash apply&lt;/li&gt;
      &lt;li&gt;git stash pop&lt;/li&gt;
      &lt;li&gt;git stash drop stash@{0}
&lt;a id=&quot;remote-link-to-the-github-or-others&quot;&gt;&lt;/a&gt;
        &lt;h2 id=&quot;remote-link-to-the-github-or-others&quot;&gt;Remote (link to the github or others)&lt;/h2&gt;
        &lt;img src=&quot;http://img.blog.csdn.net/20151001194223393&quot; alt=&quot;Remote Git&quot; /&gt;
Easily, this can be changed to
&lt;img src=&quot;http://img.blog.csdn.net/20151001194446158&quot; alt=&quot;Remote Git now&quot; /&gt;
&lt;a id=&quot;set-up-a-github-account&quot;&gt;&lt;/a&gt;
        &lt;h3 id=&quot;set-up-a-github-account&quot;&gt;Set up a github account&lt;/h3&gt;
      &lt;/li&gt;
      &lt;li&gt;you set up a account&lt;/li&gt;
      &lt;li&gt;Create a repository&lt;/li&gt;
      &lt;li&gt;look at the code following
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;echo #  &amp;gt;&amp;gt; README.md
git init
git add README.md
git commit -m &quot;first commit&quot;
git remote add origin https://github.com/[User account]/[project name].git
git push -u origin master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;you can easy use 
     git remote rm origin&lt;/li&gt;
  &lt;li&gt;git branch -a/-r&lt;/li&gt;
  &lt;li&gt;git push -f&lt;/li&gt;
  &lt;li&gt;git fetch
    &lt;ul&gt;
      &lt;li&gt;fetch before work&lt;/li&gt;
      &lt;li&gt;fetch before push&lt;/li&gt;
      &lt;li&gt;fetch often&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;git pull = git fetch + git merge&lt;/li&gt;
  &lt;li&gt;git push origin :your branch&lt;/li&gt;
  &lt;li&gt;git push origin [–delete] branch
    &lt;blockquote&gt;
      [远程分支的使用]
git checkout -b [new_branch]
(make some change)
git commit -am “word”
git push [远程仓库名] [远程分支名(new_branch)]
&lt;a id=&quot;password-caching&quot;&gt;&lt;/a&gt;
      &lt;h3 id=&quot;password-caching&quot;&gt;password caching&lt;/h3&gt;
      &lt;a href=&quot;https://help.github.com/articles/caching-your-github-password-in-git/&quot;&gt;Password Caching&lt;/a&gt;
or save the ssh key.
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sat, 18 Jun 2016 00:00:00 +0000</pubDate>
        <link>https://clendy.github.io/2016/06/18/Git-Beginner/</link>
        <guid isPermaLink="true">https://clendy.github.io/2016/06/18/Git-Beginner/</guid>
        
        <category>git</category>
        
        
      </item>
    
  </channel>
</rss>
