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 (NOTE: 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 HEAD~


git reset HEAD to-undo-file


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


git clone -b my-branch

Clone a Fast R-CNN COCO branch:

git clone --recursive -b coco
  • Save git username/password on Git for Windows

Create .git-credentials to save git username/password: 
git config --global credential.helper store

Re-run git bash.

  • One way to address SSL certificate problem

SSL certificate problem:

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

The easiest way is to disable the SSL CERT verification (This will prevent CURL to verity the HTTPS certification):

git config --global http.sslVerify false

For one repository only:

git config http.sslVerify falseSoluton


Remove all local branches which are remotely deleted

git fetch -p
  • Failed to connect to port 443: Timed out

GitHub - failed to connect to github 443 windows/ Failed to connect to gitHub - No Error

Keeping a brach of a forked repo up-to-date

git clone
cd caffe_cuhk
git checkout master-with-comment
git remote add upstream
git fetch upstream
git pull upstream master

Then do some conflicts merging jobs…


git push


Find and restore a deleted file from commit history

git checkout $commit~1 filename