Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.33 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. git reset --hard
  2. git clean -f -d
  3.  
  4.  
  5. Description:
  6. ============
  7. Git Tips: Remove untracked files and directories from the working
  8. tree when switching branches or checking out different commits.
  9.  
  10. Explanation:
  11. ============
  12. When switching branches or checking out another set of commits,
  13. you might want to only have the files and directories that are
  14. a part of that actual version. The commands shown above will
  15. accomplish this.
  16.  
  17. Be warned that any untracked files will be deleted, along with
  18. changes to tracked files. The two commands together reset the
  19. index and working tree, so ensure that any changes you don't want
  20. to lose were either committed to another branch or otherwise
  21. backed up somehow.
  22.  
  23.  
  24. Reference:
  25. ==========
  26. git reset --hard
  27. http://www.kernel.org/pub/software/scm/git/docs/git-reset.html
  28. Resets the index and working tree. Any changes to tracked files
  29. in the working tree since <commit> are discarded.
  30.  
  31. git clean -f -d
  32. http://www.kernel.org/pub/software/scm/git/docs/v1.7.6/git-clean.html
  33. -d
  34. Remove untracked directories in addition to untracked files. If an untracked directory is managed by a different git repository, it is not removed by default. Use -f option twice if you really want to remove such a directory.
  35.  
  36. -f
  37. --force
  38. If the git configuration variable clean.requireForce is not set to false, git clean will refuse to run unless given -f or -n.