How to restore locally deleted files using git
Answer:
To restore all the locally deleted files (but before commit), you can use the following command:
# git ls-files -d | xargs git checkout --
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to restore locally deleted files using git
Answer:
To restore all the locally deleted files (but before commit), you can use the following command:
# git ls-files -d | xargs git checkout --
How to delete a branch in Git
Answer:
Assume you have a branch called "feature1", and you want to delete it locally, you can use:
# git branch -d feature1
How to push to origin but a different branch using Git
Answer:
Assume you normally push your local changes to the remote's master branch, but what if you want to push the changes into another branch (e.g. testing)?
You can easily do this by using the command:
# git push origin master:testing
How do I make git ignore mode changes
Answer:
By default, if you have changed the file permission, git will also count the changes in file mode , e.g.
# git diff TEST.txt
diff --git a/TEST.txt b/TEST.txt
old mode 100644
new mode 100755
To ignore, simply type
# git config core.filemode false
Remove un-staged files or directories from Git repository
Answer:
To remove newly added files or directories under a Git repository (but un-staged yet), do:
# git clean -fdn
Check if the files/directories are really okay to remove. Then, execute the command again without the '-n'
# git clean -fd