Linux Git Commands

Published: 02 Aug 2015 Category: linux_study

Push local modification to server

git add deep learning/paper/reinforcement
git commit -m "xxxxxx"
git push -u origin master

Solution to ERROR: “fatal: The remote end hung up unexpectedly

git config http.postBuffer 524288000
git config --global http.postBuffer 157286400

Undo last two commits which not pushed yet(Caution: this will also delete relevant local files)

git reset --hard HEAD~2

Undo commit, also roll-back codes to previous commit

git reset --hard commit_id

Undo commit, but won’t undo local codes modification

Can re-commit local changes by “git commit”:

git reset commit_id

Only view how many non-pushed commits

git status

Only view comments/descriptions of non-pushed commits

git cherry -v

View detailed informations of non-pushed commits

git log master ^origin/master

Find id of last commit

git log

Clone a particular version of commit-id

After git clone the newest repo:

git checkout [commit-id]

Convert that repo to my forked repo (stay tuned..)

Clone a specific Git branch

git clone -b

Example:

 
git clone -b my-branch https://git@github.com/username/myproject.git

Clone a Fast R-CNN COCO branch:

 
git clone --recursive -b coco https://github.com/rbgirshick/fast-rcnn.git

Save git username/password on Git for Windows

Create .git-credentials to save git username/password:

https://username:password@github.com 
git config --global credential.helper store

Re-run git bash.

One way to address SSL certificate problem

SSL certificate problem:

$ git clone https://github.com/BVLC/caffe.git
Cloning into 'caffe'...
fatal: unable to access 'https://github.com/BVLC/caffe.git/': SSL certificate problem: certificate is not yet valid

The easiest way is to disable the SSL CERT verification:

git config --global http.sslVerify false
This will prevent CURL to verity the HTTPS certification.

For one repository only:

git config http.sslVerify falseSoluton

(http://stackoverflow.com/questions/3777075/ssl-certificate-rejected-trying-to-access-github-over-https-behind-firewall)