Coder Social home page Coder Social logo

blog's People

Contributors

jkhhuse avatar

Watchers

 avatar  avatar

blog's Issues

git使用

1.创建账户

安装完成后创建账户

$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"

可以通过如下命令查看git的配置

$ git status

2.创建版本库

$ cd dir
$ mkdir repo
$ git init

会在repo目录下生成一个.git文件,用于跟踪/管理版本库。

3.添加文件

$ touch readme.txt
$ git add readme.txt

$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   readme.txt
        new file:   user git/status.jpg

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   readme.txt

3.提交文件

$ git commit -m "append"
[master (root-commit) 1e57831] append
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 readme.txt
 create mode 100644 user git/status.jpg

使用git log命令可以看到提交的日志

4.状态变化

新建一个文件,未添加前状态为“Untracked”,即未被Git版本追踪:

$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        readme.txt

nothing added to commit but untracked files present (use "git add" to track)

添加文件

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   readme.txt

commit一个文件:

jk@jk-pc /cygdrive/e/learn/git/img
$ git status
On branch master
nothing to commit, working tree clean

5.版本回退

通过git log查看提交记录

$ git log
commit 1e5783173a17ea5fc2cd9849cfa74214ef2da4e8
Author: name <[email protected]>
Date:   Mon Mar 27 04:57:05 2017 +0100

    append 

使用reset命令,回退版本

$ git reset --hard 1e5783173a17ea5fc2cd9849cfa74214ef2da4e8

6.清空工作区文件的状态

$ git checkout -- readme.txt

7.删除命令

$ git rm readme.txt

8.远程仓库

无密码配置

i) 生成ken-gen
$ ssh-keygen -t rsa -C "[email protected]"
window下把生成的私钥(id_rsa)与公钥(id_rsa.pub)拷贝到cygwin目录下:
cp /C/Users/user_name/.ssh/* /home/user_name/.ssh/

ii) 配置GitHub SSH Keys
拷贝公钥到->GitHub->Account->Settings->SSH Keys

本地仓库与远程仓库关联

i) 本地创建仓库

$ mkdir repo
$ cd repo
$ git init
$ touch readme.txt
$ git add readme.txt
$ git commit -m "test"

ii) 创建远程仓库
在Github中创建一个同名仓库
iii) 把本地仓库内容推送到远程仓库

$ git remote add origin [email protected]:jkhhuse/repo.git

iv) 把本地仓库内容推送到远程仓库

$ git push -u origin master

加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,
还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。

克隆远程仓库到本地
$ git clone [email protected]:jkhhuse/repo.git

9.分支管理

分支操作

i) 创建分支

$ git checkout -b dev
#相当于
$ git branch dev #创建分支
$ git checkout dev #切换到dev分支

ii) 查看分支

$ git branch
* dev
  master

*表示当前操作的branch
iii) 合并分支
切换到master后,合并dev分支

$ git checkout master
$ git merge dev

iv) 删除分支
除非需要将分支推送到远程仓库,否则分支就是个人所见的。

$ git branch -d dev

v) 查看分支

$ git branch
更新本地仓库
$ git pull

如果出现冲突则,可以使用diff命令查看差异。

git diff <source_branch> <target_branch>
冲突处理

在merge过程中,出现的冲突时:

$ git merge feature1
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

Git用<<<<<<<,=======,>>>>>>>标记出不同分支的内容:

<<<<<<< HEAD
Creating a new branch is quick & simple.
=======
Creating a new branch is quick AND simple.
>>>>>>> feature1

修改出现冲突的文件,重新add并commit。
使用git log命令可以看到分支并不的情况:

$ git log --graph --pretty=oneline --abbrev-commit
*   59bc1cb conflict fixed
|\
| * 75a857c AND simple
* | 400b400 & simple
|/
* fec145a branch test

最后删除分支

10.标签管理

i) 切换到需要打tag的分支:

$ git branch
$ git checkout master

ii) 使用tag命令打tag:

$ git tag v1.0

iii) 使用tag查看所有tag:

$ git tag

iv) 对历史commit打tag:

$ git log --pretty=oneline --abbrev-commit
$ git tag v0.9 id前10个字符

v) 设置tag的说明:

$ git tag -a v0.1 -m "version 0.1 released" 3628164

vi) 删除tag:

$ git tag -d v0.1

vii) 推送tag到远程:
例如需要把本地的tag推送到github中:

git push origin v1.0

那么在github项目的release中就会出现刚刚推送的tag。
也可以一次性推送全部的tag:

$ git push origin --tags

如果需要删除远程tag,那么需要先删除本地tag,然后push到远程来删除远程仓库中的bug:

$ git tag -d v1.0
$ git push origin :refs/tags/v1.0

参考内容:

Git tutorial: https://lvwzhen.gitbooks.io/git-tutorial
git - 简明指南: http://rogerdudler.github.io/git-guide/index.zh.html

sublime text markdown使用

安装插件及配置

使用Ctrl + Shift + P install Package分别安装以下插件

  • View In browser
    修改Setting - User中browser在对应OS中的安装位置:
{
    "posix": {
        "linux": {
            "firefox": "firefox -new-tab",
            "chrome": "google-chrome",
            "chrome64": "google-chrome",
            "chromium": "chromium"
        
        "linux2": {
            "firefox": "firefox -new-tab",
            "chrome": "google-chrome",
            "chrome64": "google-chrome",
            "chromium": "chromium"
        },
        "darwin": {
            "firefox": "open -a \"/Applications/Firefox.app\"",
            "safari": "open -a \"/Applications/Safari.app\"",
            "chrome": "open -a \"/Applications/Google Chrome.app\"",
            "chrome64": "open -a \"/Applications/Google Chrome.app\"",
            "yandex": "open -a \"/Applications/Yandex.app\""
        }
    },
    "nt": {
        "win32": {
            "firefox": "F:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe -new-tab",
            "iexplore": "F:\\Program Files\\Internet Explorer\\iexplore.exe",
            "chrome": "F:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
            "chrome64": "F:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
            "yandex": "%Local AppData%\\Yandex\\YandexBrowser\\browser.exe"
        }
    },

    "browser": "chrome64"
}
  • Markdown Editing
    修改Markdown GFM Settings - User配置
    warp_width为移除插件在编辑markdown文件时左侧出现空白区域的问题
    color_scheme为设置背景色
{
    "draw_centered": true,
    "word_wrap": true,
    "wrap_width": 210,
    "rulers": [],
    "color_scheme": "Packages/MarkdownEditing/MarkdownEditor-Dark.tmTheme",
}
  • Markdown Preview
  • Auto Save
    设置自动保存时
{
    "auto_save_delay_in_seconds": 1,
}

创建Markdown文件

使用Ctrl + N新建一个文件
在正文中输入文字
Ctrl + Shift + P 输入ssm(set syntax: markdown)
Ctrl + S 保存为mdown文件

实时编辑/查看Markdown文件

  1. 设置快捷键
[
    {"keys": ["alt+m"], "command": "markdown_preview", "args": { "target": "browser"}}
]
  1. 编辑Markdown文件
    在文件末尾添加:来设置实时刷新的频率
  2. 设置定时保存文件
    Ctrl + Shift + P 输入auto,选择Save Current File Only
  3. 打开html文件
    使用快捷键Alt + M 打开
  4. 在html页面选择View In Brower

通过以上设置,可以实现定时保存markwodn文件,并同步刷新在浏览器端的效果。

angular跳转到新页面后返回到上一页,返回到上一页跳转前的状态

问题:angularJs列表中点击某条记录,跳转到新页面。当返回到列表后,仍然可以回到跳转前的页码处。
要做到上述效果,要把分页中的currentPage填写到url中,然后在新页面的url中也添加这个page信息。

$routeParams.page 获得url中的page
$route.updateParams({page:$scope.page}) 修改url中的page信息
$routeProvider.when('/demo/:page',{
    ...
})  路由写法

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.