03 February 2015

Installation

Install the latest version of Git on CentOS 7:

  yum remove git
  yum install epel-release
  yum install https://centos7.iuscommunity.org/ius-release.rpm
  yum install git2u

Configuration

git config --global core.editor "/usr/local/bin/mvim -v"

Commit Message Format

Protocols

  1. Local protocol such as /srv/git/project.git and file:///srv/git/project.git
  2. HTTP protocols such as http://git.haproxy.org/git/haproxy-1.9.git and https://chromium.googlesource.com/external/webrtc.
  3. SSH protocol such as git@github.com:yaojingguo/c-code.git and ssh://git@github.com/yaojingguo/c-code.git
  4. Git protocol. A URL is prefixed with git://.

Tips

git push origin --delete <branchName>

To see an old version of a file, use git show REVISION:path/to/file. For example, to show the 4th last commit of the file src/main.c, use git show HEAD~4:src/main.c.

Text File Merge

Conflicts if:

  • Both branches modify the same line
  • Two branches modify continuous lines. For example, branch A modifies line 1. Branch B modifies line 2.

No conflicts if:

  • One branch modifies one line. The other branch add a new line.
  • Both branches add new line (adding lines means inserting lines or appending lines).

Proxy

The following configuration impacts both HTTP and HTTPS git URLs. But a http_proxy environment variable only applies to Git HTTP URLs. https_proxy environment variable only applies to Git HTTPS URLs.

A HTTP proxy is used:

[http]
  proxy = www.proxy.com:80

Or a SOCKS5 proxy can also be used:

[http]
  proxy = socks5://127.0.0.1:1080

The above configuration is equivalent to http.proxy. There is no https.proxy for Git.

Shadowsocks client listens on socks5://127.0.0.1:1080 by default. Proxifier is not needed.

Pack

Diff

##

package main

import "fmt"

func main() {
	fmt.Println("hello, world")
}

Remve the line for Println. git diff produces:

diff --git a/main.go b/main.go
index 50e8d8d..ba4f19d 100644
--- a/main.go
+++ b/main.go
@@ -3,5 +3,4 @@ package main
 import "fmt"

 func main() {
-       fmt.Println("vim-go")
 }

makeNodeMetrics

writeFileSyncing

MISC