我的站点

一个系统软件工程师的随手涂鸦

Tag: git (Page 1 of 4)

git小技巧(11)——如何checkout一个remote branch

参考自Stackoverflow

git checkout -b <BRANCH-NAME> <REMOTE-NAME>/<BRANCH-NAME>

git小技巧(10)——如何同original master进行rebase

original repositorymaster branch rebase的方法:
(1)

git fetch origin # Updates origin/master
git rebase origin/master # Rebases current branch onto origin/master

(2)

git pull --rebase origin master

参考资料:
How to rebase local branch with remote master

git小技巧(9)——避免提交时每次输入用户名和密码

避免每次提交改动时输入用户名和密码,可以使用下列命令:

$ git config credential.helper store
$ git push https://github.com/username/repo.git

参考资料:
Git push: username, password, how to avoid?

*NIX & Hacking —— 第10期

做一本我感兴趣的杂志,就这么简单!

Git

Some of git internals

Kernel

A History of Linux Kernel Module Signing
Linux Kernel Hacking Talk

KVM

Using the KVM API

Tracing

Linux Networking, Tracing and IO Visor, a New Systems Performance Tool for a Distributed World

Unix

Syscall table reference tool for several arch(Linux x86/64,ARM,IA64,Winx86/64,OSX BSD & more)

Vim

A vim Tutorial and Primer

X86

A Primer on Disassembling Function Calls and Understanding Stack Frames in x86
Advanced x86: Introduction to BIOS & SMM

Easter Egg

Awesome Open Source Documents
Closing a door

Suse使用初体验

这两天折腾了一下SuseSLES 12 Beta版本),感觉和RedHat系列还是有一些不同。记录下来,以备以后查找:

(1)YaST2

YaST (Yet another Setup Tool)2Suse系统上的配置工具的:

Capture

感觉很好用。配置网络,FTPProxy等等,很方便。另外,单击图标就可以启动软件了,让用惯了“双击”的我开始不大适应。

(2)zypper

命令行安装软件使用zypper命令(in代表install):

zypper in git-core

卸载(rm):

zypper rm git-core

另外注意,git包的名字叫git-core

(3)命令窗口

使用Alt + F2快捷键可以调出命令窗口:

Capture1

输入gnome-terminal可以打开一个终端。

(4)supportconfig

Suse提供了supportconfig工具,用来抓取系统的信息,对debugging提供了很大的帮助:

Capture

 

 

*NIX & Hacking —— 第8期

做一本我感兴趣的杂志,就这么简单!

C

C Programming Substance Guidelines
The International Obfuscated C Code Contest

Docker

A Beginners Guide to Docker and Containers

Gcc

About GCC printf optimization

Git

Git Cheat Sheet
Git Tips

Hardware

Interfacing the Serial / RS232 Port

Kernel

Porting Linux to a new processor architecture, part 1: The basics
The newbie’s guide to hacking the Linux kernel
Writing a Linux Kernel Module — Part 1: Introduction

Lua

Embedding LuaJIT in 30 minutes (or so)

Network

Mobile TCP optimization – lessons learned in production

Unix

The First Port Of Unix

git小技巧(8)——“git checkout – ”

git checkout -切换到之前工作的branch。请看例子:

[root@localhost debugging-stories]# git branch
  master
  patch-1
* patch-2
[root@localhost debugging-stories]# git checkout -
Switched to branch 'patch-1'
[root@localhost debugging-stories]# git branch
  master
* patch-1
  patch-2

可以看到切换到了patch-1 branch

 

git branch & merge笔记

In fact, in Git, the act of creating a new branch is simply writing a file in the .git/refs/heads directory that has the SHA-1 of the last commit for that branch.

Creating a branch is nothing more than just writing 40 characters to a file.

Switching to that branch simply means having Git make your working directory look like the tree that SHA-1 points to and updating the HEAD file so each commit from that point on moves that branch pointer forward (in other words, it changes the 40 characters in .git/refs/heads/[current_branch_name] be the SHA-1 of your last commit).

可以看到,在git中,创建一个branch仅仅是在一个文件中加入40个字符的SHA-1值。

Remotes are basically pointers to branches in other peoples copies of the same repository, often on other computers. If you got your repository by cloning it, rather than initializing it, you should have a remote branch of where you copied it from automatically added as origin by default. Which means the tree that was checked out during your initial clone would be referenced as origin/master , which means “the master branch of the origin remote.”

Remotes是指向其它人关于这个repository copy里某个branch的指针。如果你的repository是通过clone其它copy得到的,而不是initialize的,在你的repository里,会自动产生一个origin/masterremote branch指向你copyrepository tree

参考资料:
Git internals

Git数据模型笔记

Git object数据是一个有向无环图,即从任何一个commit出发都可以遍历其任何的parent,但绝不会有环。每个commit都指向一个tree,而一个tree则指向了一个或多个tree和(或)blob

Git数据模型如下图所示:

1

以下面目录结构为例:

2

工作目录下包含了两个目录和三个文件。初始化的git数据模型如下:

3

当修改lib/base/base_include.rb这个文件并提交以后,会产生一个新的blob以及相应的新tree。在当前commit打出tag以后,git数据模型如下:

4

修改根目录下init.rb文件提交后的git数据模型:

5

可以看到,每次commit都会产生一个新的tree
最后的git数据模型如下图所示,包含了16个不可改变的object

6

 

 

参考资料:
Git internals

git小技巧(7)——“git format-patch ..

git format-patch <rev1>..<rev2>会产生两个commit之间的patch<rev>commit ID)。请看例子:

[root@localhost linux]# git format-patch 9f10e5bf62f7b9937afeee8ff0a491f87438e2a2..571dbbd4d044e11c78bc077acb3ccef4c77b096e
0001-iommu-vt-d-Init-QI-before-root-entry-is-allocated.patch
0002-iommu-vt-d-Make-root-entry-visible-for-hardware-righ.patch
0003-iommu-vt-d-Detect-pre-enabled-translation.patch
0004-iommu-vt-d-Copy-translation-tables-from-old-kernel.patch
0005-iommu-vt-d-Do-not-re-use-domain-ids-from-the-old-ker.patch
0006-iommu-vt-d-Mark-copied-context-entries.patch
0007-iommu-vt-d-Allocate-si_domain-in-init_dmars.patch
0008-iommu-vt-d-Don-t-do-early-domain-assignment-if-kdump.patch
0009-iommu-vt-d-Don-t-copy-translation-tables-if-RTT-bit-.patch
0010-iommu-vt-d-Don-t-disable-translation-prior-to-OS-han.patch
0011-iommu-vt-d-Enable-Translation-only-if-it-was-previou.patch
0012-iommu-vt-d-Move-EIM-detection-to-intel_prepare_irq_r.patch
0013-iommu-vt-d-Move-QI-initializationt-to-intel_setup_ir.patch
0014-iommu-vt-d-Disable-IRQ-remapping-in-intel_prepare_ir.patch
0015-iommu-vt-d-Set-IRTA-in-intel_setup_irq_remapping.patch
0016-iommu-vt-d-Copy-IR-table-from-old-kernel-when-in-kdu.patch
0017-iommu-vt-d-Make-sure-copied-over-IR-entries-are-not-.patch
0018-iommu-vt-d-Don-t-disable-IR-when-it-was-previously-e.patch

但是这个命令不会包含<rev1>这个commit产生的patch。要想包含<rev1>这个commit产生的patch,需要在<rev1>后加上~,代表<rev1>之前的commit。请看例子:

[root@localhost linux]# git format-patch 9f10e5bf62f7b9937afeee8ff0a491f87438e2a2~..571dbbd4d044e11c78bc077acb3ccef4c77b096e
0001-iommu-vt-d-Cleanup-log-messages.patch
0002-iommu-vt-d-Init-QI-before-root-entry-is-allocated.patch
0003-iommu-vt-d-Make-root-entry-visible-for-hardware-righ.patch
0004-iommu-vt-d-Detect-pre-enabled-translation.patch
0005-iommu-vt-d-Copy-translation-tables-from-old-kernel.patch
0006-iommu-vt-d-Do-not-re-use-domain-ids-from-the-old-ker.patch
0007-iommu-vt-d-Mark-copied-context-entries.patch
0008-iommu-vt-d-Allocate-si_domain-in-init_dmars.patch
0009-iommu-vt-d-Don-t-do-early-domain-assignment-if-kdump.patch
0010-iommu-vt-d-Don-t-copy-translation-tables-if-RTT-bit-.patch
0011-iommu-vt-d-Don-t-disable-translation-prior-to-OS-han.patch
0012-iommu-vt-d-Enable-Translation-only-if-it-was-previou.patch
0013-iommu-vt-d-Move-EIM-detection-to-intel_prepare_irq_r.patch
0014-iommu-vt-d-Move-QI-initializationt-to-intel_setup_ir.patch
0015-iommu-vt-d-Disable-IRQ-remapping-in-intel_prepare_ir.patch
0016-iommu-vt-d-Set-IRTA-in-intel_setup_irq_remapping.patch
0017-iommu-vt-d-Copy-IR-table-from-old-kernel-when-in-kdu.patch
0018-iommu-vt-d-Make-sure-copied-over-IR-entries-are-not-.patch
0019-iommu-vt-d-Don-t-disable-IR-when-it-was-previously-e.patch

可以看到多产生了一个patch

Page 1 of 4

Powered by WordPress & Theme by Anders Norén