How do I remove a directory from a Git repository?

Remove directory from Git and local Checkout ‘master’ with both directories: git rm -r one-of-the-directories // This deletes from filesystem git commit . -m “Remove duplicated directory” git push origin <your-git-branch> (typically ‘master’, but not always) Remove directory from Git but NOT local To remove this directory from Git but not delete it entirely from … Read more

How do I undo ‘git reset’?

Short answer: git reset ‘HEAD@{1}’ Long answer: Git keeps a log of all ref updates (e.g., checkout, reset, commit, merge). You can view it by typing: git reflog Somewhere in this list is the commit that you lost. Let’s say you just typed git reset HEAD~ and want to undo it. My reflog looks like … Read more

Is there a way to configure git repository to reject ‘git push –force’?

Setting the configuration variables: receive.denyNonFastForwards receive.denyDeletes will prevent any ‘forced’ pushes from working across all branches. If you want finer pre-branch control then you will have to use a ‘hook’ on the remote repository, probably the ‘update’ hook. There is a sample update hook called ‘update-paranoid’ that probably does what you need (and more) in … Read more

What are .git/info/grafts for?

From Git Wiki: Graft points or grafts enable two otherwise different lines of development to be joined together. It works by letting users record fake ancestry information for commits. This way you can make git pretend the set of parents a commit has is different from what was recorded when the commit was created. Reasons … Read more