Learn Git
Git Book读书笔记: https://git-scm.com/book/en/v2
Get git repository
两种方法:
1 从本地目录创建
1) cd e:/mynotes
2) git init
3) git add *.c
4) git add LICENSE
5) git commit -m ‘initial project version’
删除文件用 git rm。 从git版本库中删除文件但不在磁盘上删除:1
2git rm -r public/ --cached
git commit -m "remove public folder from git"
清除目录下未跟踪的目录及文件:1
git clean -df
2 从远程clone一个仓库到本地
git clone https://github.com/libgit2/libgit2
git clone https://github.com/libgit2/libgit2 mylibgit
Others
git add is a multipurpose command. git add是一个多功能的命令:
to begin tracking new files
to stage files
to do other things like marking merge-conflicted files as resolved
It may be helpful to think of it more as “add precisely this content to
the next commit” rather than “add this file to the project”.
忽略某些文件的方法,添加.gitignore文件:
https://github.com/github/gitignore
# ignore all .a files
*.a
# but do track lib.a, even though you're ignoring .a files above
!lib.a
# only ignore the TODO file in the current directory,
#not subdir/TODO
/TODO
# ignore all files in any directory named build
build/
# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt
# ignore all .pdf files in the doc/ directory
# and any of its subdirectories
doc/**/*.pdf
git log
1 | git log |
Undo
$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend
You end up with a single commit — the second commit replaces the
results of the first.
remote
1 | git remote |
Adding Remote Repositories
$ git remote
origin
$ git remote add pb https://github.com/paulboone/ticgit
$ git remote -v
origin https://github.com/schacon/ticgit (fetch)
origin https://github.com/schacon/ticgit (push)
pb https://github.com/paulboone/ticgit (fetch)
pb https://github.com/paulboone/ticgit (push)
Fetching and Pulling from Your Remotes
git fetch remote
The command goes out to that remote project and pulls down all the data
from that remote project that you don’t have yet.\
It’s important to note that the git fetch command only downloads the
data to your local repository: it doesn’t automatically merge it with
any of your work or modify what you’re currently working on. You have to
merge it manually into your work when you’re ready.
If your current branch is set up to track a remote branch (see the next
section and Git Branching for more information), you can use the git
pull command to automatically fetch and then merge that remote branch
into your current branch.
Pushing to Your Remotes
git push remote branch
git push origin master
Inspecting a Remote
git remote show remote
git remote show origin
$ git remote show origin
* remote origin
Fetch URL: https://github.com/schacon/ticgit
Push URL: https://github.com/schacon/ticgit
HEAD branch: master
Remote branches:
master tracked
dev-branch tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
Renaming and Removing Remotes
You can run git remote rename to change a remote’s shortname. For
instance, if you want to rename pb to paul, you can do so with git
remote rename:
$ git remote rename pb paul
$ git remote
origin
paul
remove a remote:
git remote remove paul
git remote rm
Listing your tags(显示tag)
1 | git tag |
Creating tags
Git 支持两种 tags: lightweight and annotated.
A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit.
Annotated tags, however, are stored as full objects in the Git database. 一般使用annotated tag.
创建Annotated tag:
1
2
3git tag -a v1.4 -m "my version 1.4"
//查看annotated tag:
git show v1.4创建Lightweight Tags
1
2git tag v1.4-lw
git show v1.4-lw
以上是对当上次commit进行打tag。
若要对之前某次commit打tag:
首先假设如下是之前的提交历史记录:1
2
3
4
5
6
7
8
9
10
11$ git log --pretty=oneline
15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment'
a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support
0d52aaab4479697da7686c15f77a3d64d9165190 one more thing
6d52a271eda8725415634dd79daabbc4d9b6008e Merge branch 'experiment'
0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc added a commit function
4682c3261057305bdd616e23b64b0857d832627b added a todo file
166ae0c4d3f420721acbb115cc33848dfcc2121a started write support
9fceb02d0ae598e95dc970b74767f19372d61af8 updated rakefile
964f16d36dfccde844893cac5b347e7b3d44abbc commit the todo
8a5cbc430f1a9c3d00faaeffd07798508422908a updated readme
为了在message为”updated rakefile”上打tag,只需要在git tag -a v1.2 后面加上校验和的(前面的)一部分即可。如下:1
git tag -a v1.2 9fceb02
把tag推送到remote server
默认情况下,git push
不会把tag推送到服务器,推送方法:git push origin 1
2
3git push origin v1.5
//或者
git push origin --tags // 把所有tag推送到remote server
Delete tags 删除tags
删除本地tag:git tag -d <tagname>
1 | git tag -d v1.4-lw |
删除remote server上的tags:
1 | git push origin --delete <tagname> |
查看远程所有的分支和tag:1
git ls-remote
Git alias
1 | $ git config --global alias.co checkout |
也可用于自定义命令:1
$ git config --global alias.unstage 'reset HEAD --' //添加unstage命令
所以以下两条命令就等价了:1
2$ git unstage fileA
$ git reset HEAD -- fileA
另外,可以添加一个last命令,查看上一次的commit情况:1
$ git config --global alias.last 'log -1 HEAD'
之后,想查看上次的commit情况,只需输入:git last
Creating a New Branch
1 | git branch newbranchname |
HEAD是一个特殊的指针,指向当前工作的branch. 可以用git log可查看其指向:1
git log --oneline --decorate
Switching Branches
1 | git checkout abranchname // HEAD指针会指向abranchname分支 |
Scritpable render pipleline
Unity Scriptable Render Pipeline (SRP)学习笔记
可编写脚本的渲染管线?
参考链接:
SRP概述
SRP是新的Unity特性(目前于预览版,以后可能会发生大的变动),可使开发者完全掌控Unity渲染管线,允许开发者写C#脚本控制Unity渲染每一帧的方式。
可以在 Unity 2018.1+版本中使用.
SRP可以分为两部分: SRP asset和SRP instance。两者在自制渲染管线时都很重要。
SRP Asset
SRP Asset是一个project asset,表示渲染管线的一个具体配置(specific configuration),例如:
- 是否应该投下阴影
- 使用什么着色器质量级别(shader quality level)
- 阴影距离是多少
- 默认材质配置
SRP Asset表示SRP的类型(type)和配置(settings)。
SRP Instance
**SRP instance是实际完成渲染(rendering)的类(class)。
当Unity发现SRP开启时,它会查看当前使用的SRP asset,要求其提供一个’rendering instance’。
SRP Instance表示一个管道配置(pipeline configuration)。渲染器调用Instance,则可以完成以下动作:
- 清除帧缓存(Clearing the framebuffer)
- 完成场景剔除(Performing scene culling)
- 渲染一些对象(Rendering sets of objects)
- 完成blit操作(Doing blits from one frame buffer to another)
- 渲染阴影(Rendering shadows)
- 实施后处理效果(Applying post process effects)
简单的SRP例子
由上面的叙述可知,SRP Asset是一个ScriptableObject,它包含渲染管线相关的配置,可以返回一个渲染管线实例,用于渲染,替代Unity标准的渲染(standard Unity rendering)。
如果SRP asset上的一个设置(setting)发生了改变,所有对应的已创建的SRP instance将会被销毁,并在渲染下一帧时创建新的instance(带有改变后的新设置settings)。
下面是一个简单地SRP asset类,它包含一个color,由返回的Instance使用,使用clearColor来清除屏幕。
其中CreateBasicAssetPipeline()
方法只能在Editor模式下使用,它用于创建这个asset。
1 | [ExecuteInEditMode] |
上面代码InternalCreatePipeline()
返回的BasicPipeInstance
即为SRP Instance。必须实现创建Instance类,因为所有的渲染逻辑都在它里面。
最简单的SRP Instance可以仅包含一个Render
方法,有两个参数,如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22public class BasicPipeInstance : RenderPipeline
{
private Color m_ClearColor = Color.black;
public BasicPipeInstance(Color clearColor)
{
m_ClearColor = clearColor;
}
public override void Render(ScriptableRenderContext context, Camera[] cameras)
{
// does not so much yet :()
base.Render(context, cameras);
// clear buffers to the configured color
var cmd = new CommandBuffer();
cmd.ClearRenderTarget(true, true, m_ClearColor);
context.ExecuteCommandBuffer(cmd);
cmd.Release();
context.Submit();
}
}
这个pipeline就是完成了使用给定的颜色m_ClearColor
来清除屏幕。注意:
- CommandBuffer可以用来完成许多操作(此处是ClearRenderTarget )
- CommandBuffer被放入context中
- 渲染的最后一步是调用Submit,这会执行渲染环境(render contex)中放入的队列
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick Start
Create a new post
1 | $ hexo new "My New Post" |
More info: Writing
Run server
1 | $ hexo server |
More info: Server
Generate static files
1 | $ hexo generate |
More info: Generating
Deploy to remote sites
1 | $ hexo deploy |
More info: Deployment