Linux Git Commands
- 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~
or:
git reset HEAD to-undo-file
or:
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 (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 github.com port 443: Timed out
 
GitHub - failed to connect to github 443 windows/ Failed to connect to gitHub - No Error
- stackoverflow: http://stackoverflow.com/questions/18356502/github-failed-to-connect-to-github-443-windows-failed-to-connect-to-github
 
Keeping a brach of a forked repo up-to-date
git clone https://github.com/handong1587/caffe_cuhk
cd caffe_cuhk
git checkout master-with-comment
git remote add upstream https://github.com/BVLC/caffe
git fetch upstream
git pull upstream master
Then do some conflicts merging jobs…
Finally:
git push
-ref: https://gist.github.com/CristinaSolana/1885435
Find and restore a deleted file from commit history
git checkout $commit~1 filename