The work flow of using github

This post is a reference about how to contribute to others’ github projects:

(1) Fork the project into your account:

1(2) Clone your project, and enter the directory:

$ git clone<username>/project.git
$ cd project

Set the upstream:

$ git remote add upstream<upstream>/project.git
$ git remote set-url --push upstream no-pushing

(3) Synchronize the upstream and origin branch timely:

$ git pull upstream master

(4) If you want to submit “Pull Request”, create a new branch based on master and develop in this branch:

$ git checkout master
$ git checkout -b patch-1
$ vi
$ git commit -a -m "Edited README"
$ git push origin patch-1

(5) Then you can send “Pull Request” to upstream:



Switch to https when git protocol doesn’t work

For many reasons (such as Firewall), you can’t clone from remote server’s git port(by default: 9418) correctly. For example:

# git clone git:// -b perf/core
Cloning into 'linux'...

From the captured packet:


You can see the TCP connection is established, then no any response! You can switch to https or http protocol, it may save your life:

# git clone -b perf/core
Cloning into 'linux'...
POST git-upload-pack (gzip 25015 to 12570 bytes)
remote: Counting objects: 5287534, done.

Please refer the discussion here.

Use Source Insight as the editor to develop Unix softwares

Source Insight is my favorite editor, and I have used it for more than 10 years. But when employing it to develop Unix software, you will run into annoying line break issue, which is on windows, the newline is \r\n while in Unix it is \n only. Therefore you will see the file edited in Source Insight will display an extra ^M in Unix environment:

#include <stdio.h>^M
int main(void)^M

To resolve this problem, you can refer this topic in stackoverflow:

To save a file with a specific end-of-line type in Source Insight, select File -> Save As…, then where it says “Save as type”, select the desired end-of-line type.

To set the end-of-line type for new files you create in Source Insight, select Options -> Preferences and click the Files tab. Where it says “Default file format” select the desired end-of-line type.

So you can set Unix file format as you wanted:


Another caveat you should pay attention is if you use git Windows client, by default, it will convert the newline of project from \n to \r\n directly. My solution is just disabling this auto conversion feature:

git config --global core.autocrlf false

How to access git repository through http proxy?

  1. Install socat. E.g., on SUSE:
    zypper in socat
  2. Download this file:
    # Use socat to proxy git through an HTTP CONNECT firewall.
    # Useful if you are trying to clone git:// from inside a company.
    # Requires that the proxy allows CONNECT to port 9418.
    # Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
    #   chmod +x gitproxy
    #   git config --global core.gitproxy gitproxy
    # More details at
    # Configuration. Common proxy ports are 3128, 8123, 8000.
    exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
  3. Rename its name as gitproxy, and modify _proxy and _proxyport.
  4. Copy it into your PATH , e.g., /usr/bin.
  5. Switch to the directory which contains gitproxy, and execute the following commands:
    # chmod +x gitproxy
    # git config --global core.gitproxy gitproxy
  6. Now, git clone git://... will work!