• force reset to the version of the last two 取消当前版本之前的两次提交
git reset --hard HEAD~2 
  • force push to the remote re 强制提交到远程版本库,从而删除之前的两次提交数据
git push origin HEAD --force
标签: git
日期: 2014-06-20 17:30:06, 10 years and 210 days ago

在Github上建立一个SVN的镜像库

1.Create repository 创建库

2.clone the git repository 克隆代码至本地

$git clone git@github.com:user-name/repository-name

3.set svn as a remote repository 把svn仓库添加为远程仓库

$git svn init -T http://url/svn/trunk/

4.fetch 获取svn仓库的代码

$git svn fetch

5.show all branch 显示所有分支

$git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/trunk

remotes/trunk is the svn branch 其中,remotes/trunk为svn分支

6.merge 合并svn分支

$git merge trunk

7.push 推送至github

$git push

refference

在GitHub上建立一个SVN仓库的镜像

标签: git
日期: 2014-03-21 17:30:06, 10 years and 301 days ago

show commit count 显示提交记录数

git rev-list HEAD --count

combine commit or modify commit message 合并或修改记录

  • command 命令
git rebase -i HEAD~$x

其中$x代表你期望操作的记录数,小于提交记录数 $x is the count of commit that you want to combine or change, $x is less than commit count

如 e.g.

你想操作最后十条,则$x为10 if you want to change the last ten commits, the value of $x is 10.

pick 123456 init
pick 7890ab add text
pick cdef12 modify text
pick 345678 modify text

  • edit 编辑

change the "pick" that is in front of the commit line to "s", the commit will combine to previous commit. 在你期望合并的commit将前面的pick更改成s就行, 此条commit将于上一条commit合并

change the "pick to "r", the commit message will be modify. pick改成r表示修改当前提交信息

e.g.例如:

"pick 345678 modify text" --> "s 345678 modify text"

  • change commit message after saving 保存后,重新编写提交信息
 # This is a combination of 2 commits.
 # The first commit's message is:

 modify text

 # This is the 2nd commit message:

 modify text

 # Please enter the commit message for your changes. Lines starting
 # with '#' will be ignored, and an empty message aborts the commit.
 # HEAD detached at 8658d47
 # You are currently editing a commit while rebasing branch 'master' on 'ddcff57'.
 #
 # Changes to be committed:
 #   (use "git reset HEAD^1 ..." to unstage)
 #
 #  new file:   ignorelist
 #  modified:   README.md
 #
 # Untracked files:
 #   (use "git add ..." to include in what will be committed)
 #
 change text

 # Please enter the commit message for your changes. Lines starting
 # with '#' will be ignored, and an empty message aborts the commit.
 # HEAD detached from 18e598b
 # You are currently editing a commit while rebasing branch 'master' on 'ddcff57'.
 #
 # Changes to be committed:
 #   (use "git reset HEAD^1 ..." to unstage)
 #
 #  new file:   README.md
 #
 # Untracked files:
 #   (use "git add ..." to include in what will be committed)
 #
  • push 推送至远程
git push -f
标签: git
日期: 2014-03-07 17:30:06, 10 years and 315 days ago
  • Register 注册

  • Create repository 创建库
    新建库 可以在任何有权限的账户上创建库,无论是个人或组织帐号

    1. 在任意页面的右上角的用户条,点击“Create a New Repo"按钮
    2. 选择创建库的帐号
    3. 输入库名字,选择库类型public公有或private私有;然后点击“Create repository”
  • Delete repository 删除库 删除库

    1. 切换至要删除的库
    2. 选择库操作条上的“Settings”
    3. 点击“Delete this repository”在Danger Zone 区域
    4. 阅读警告,输入库名
    5. 点击“I understand the consequences, delete this repository”
  • Establish a secure connectio SSH Keys 如果决定不使用推荐的HTTPS方法,也能用SSH keys去建立一个安全的终端到github的链接, 下面的步骤将引导你产生一个SSH key然后加入公钥到github帐号

    1. 检查SSH keys 首先,我们需要检查一个存在的ssh keys在你的计算机。 cd ~/.ssh 如果没有文件或路路,那么进行第二步,否则密钥对已存在那么跳到第三步。
    2. 产生新的SSH key 产生新的SSH key ssh-keygen -t rsa -C "your_email@example.com"
    3. 加入SSH key到GitHub 拷贝公钥到剪切版 ~/.ssh/id_rsa.pub
      1. 进入账户设置“Account Settings”
      2. 点击侧栏的“SSH Keys”
      3. 点击“Add SSH key”
      4. 黏贴公钥到“Key”区域
      5. 点击“Add key”
      6. 确认密码后,添加成功
    4. 测试 ssh -T git@github.com
标签: git
日期: 2013-04-06 17:30:06, 11 years and 285 days ago
  • Repository Configure 库配置

    • git init --bare name.git initial an empty git repository 初始化一个空git库
  • Local Setting 本地配置

    • git config user.name name 设置用户名 set user name

    • git config user.email email 设置email地址 set user email

  • Status 状态查询

    • git log --oneline --graph 显示日志 show log

    • git status -s 显示工作区状态 show work box status

  • Box - Stage 工作区和暂存区

    • git add -A 加入所有修改至缓存区 add file new file, removing file and motified content to stage

    • git add -u 加入修改内容至缓存区 update motified content to stage

    • git rm file 移除文件 remove file from work box and stage

      • git diff 比较工作区和暂存区 compare stage with HEAD(local Repository)
    • git checkout -- file 从缓存区恢复至工作区 restore file in work box from stage

  • Stage - Repository 暂存区和库

    • git reset, git reset HEAD, git reset -- file 用库重置暂存区 restore stage from repository

    • git diff --cached 比较暂存区和库 compare stage with HEAD(local Repository)

    • git commit -m 'message' 提交缓存区至库 commit stage to repository

  • Box - Repository 工作区和库

    • git diff HEAD 比较工作区和库 compare work box with HEAD(local Repository)
  • Repository - Stage - Box

    • git reset --hard HEAD 用库恢复工作区和暂存区 restore work box and stage from repository

    • git checkout [commit] -- file 检出至工作区和暂存区 checkout to work box and stage

  • Repository

    • git reset --soft HEAD^ 还原至上一版本 revert to last version(HEAD^)

    • git commit --amend -m 'new comment' modify log 修改版本日志

  • Local Repository - Remote Repository 本地库和远程库

    • git clone file://path.name.git 克隆git库 clone git repository

    • git push 更新远程库 update remote repository

    • git pull 获取远程库,合并到本地 fetch and merge remote to local

  • With SubVersioN

   
svnadmin create     git init --bare
svn checkout        git clone
svn update          git pull
svn revert          git reset git checkout --
                    git [commit] checkout --
svn add             git add
svn rm              git rm
svn mv              git mv
svn diff            git diff 
                        git diff --cached
                    git diff HEAD
svn status          git status -s
svn commit -m ''    git commit -m '';git push
svn log             git log 
  • 保存当前工作进度

    • git stash save work box to the stash 保存进度

    • git stash list 显示进度列表 list stash

    • git stash apply 恢复进度 apply a single stashed state on the top of work box

    • git stash pop 从进度列表移动某个缓存覆盖工作区 remove a single stashed state and apply it on the top of work box

    • git stash clear 删除所有存储的进度 clean the stash

标签: git
日期: 2013-03-11 17:30:06, 11 years and 311 days ago