Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Bash
Posted by: Shelane French
Added: Jan 24, 2020 9:18 PM
Modified: Jan 24, 2020 9:20 PM
Views: 6
Tags: git
  1. # for .gitignore
  2. # to exclude all svn files - .svn (no wildcards or /)
  3. # to exclude all DW notes directories and files - _notes (no wildcards or /)
  4.  
  5. # to remove a file that is tracked from being tracked
  6. git rm --cached <filename>
  7.  
  8. #to discard all current changes and revert to last commit
  9. git checkout .
  10.  
  11. # clone into current directory
  12. # directory must be empty
  13. git clone git@github.com:user/my-project.git .
  14.  
  15. #force a push to the remote
  16. git push -f <remote> <branch>
  17.  
  18. #Set user name and email
  19. git config --global user.name "Shelane French"
  20. git config --global user.email "french8@llnl.gov"
  21.  
  22. #Read user name and email
  23. git config user.name
  24. git config user.email
  25.  
  26. #List all global config
  27. git config --list
  28.  
  29. #Config file location
  30. ~/.gitconfig
  31.  
  32. # Create orphan branch
  33. cd repository
  34. git checkout --orphan orphan_name
  35. git rm -rf .
  36. rm '.gitignore'
  37. git push origin orphan_name
  38.  
  39. # Create patch:
  40. # Have both files in the same directory
  41. # from within that directory in terminal issue command
  42.  
  43. diff -u originalfile.ext newfile.ext > patchfilename.patch
  44.  
  45. # Apply patch:
  46. # Have patch file within directory
  47.  
  48. patch -p1 <patchfilename.patch