User Tools

Site Tools



Many tips I have been learning to use GIT

Recover a deleted file

nicky$: file="filepath"
nicky$: git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"

Ignore files

To ignore files, create a file named .gitignore inside the root directory of your project:

nicky$: touch .gitignore

Afterwards, fill up the file with for example:

*.exe #Every file that has this extension won't be commited
[B][b]in/ #Ignore all files of bin directory that starts either  by Bin/bin
[B][b]in/* #Ignore all subfolders of bin directory


nicky$: git add .
nicky$: git commit -m “Add ignore file”

If it is not take into account, you can reset the git cache:

nicky$: git rm -r –cached .

Note: before the word cached, there are two -

Show remote branches

$ git ls-remote --heads origin
git.txt · Last modified: 2018/12/01 17:43 by nicky