Nan Xiao's Blog

A system software / performance engineer's home

Tag: git (Page 1 of 2)

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

git rollback operations cheatsheet

Operation objects Git operations
Untracked files git clean -f: Remove all untracked files
Tracked but not committed files git reset –hard: Rollback the tracked files to last committed status
committed-ID git reset –hard committed-ID: Rollback the repository to the specified committed-ID status

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!


Install git-email on RHEL 7.0

The RHEL 7.0 ISO doesn’t provide git-email rpm package by default. Because the git rpm provided by ISO file isgit-, you should download the same version here, and install it:

[root@linux ~]# rpm -ivh git-email-
warning: git-email- Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
        perl(Authen::SASL) is needed by git-email-
        perl(Net::SMTP::SSL) is needed by git-email-

From the error message, we know also need to use yum to install perl-Net-SMTP-SSL and perl-Authen-SASL packages:

[root@linux ~]#yum install perl-Net-SMTP-SSL
[root@linux ~]#yum install perl-Authen-SASL



Page 1 of 2

Powered by WordPress & Theme by Anders Norén