Git revert modified files
# git delete local and remote
git checkout master
#delete local
git branch -D(force regular -d) <branch_name>
#delete remote
git <remote.git> --delete <branch_name>
# Revert changes to modified files.
git reset --hard
# Remove all untracked files and directories.
#(`-f` is `force`, `-d` is `remove directories`)
git clean -fd
Git undo most recent commit
#For a local commit
git reset --soft HEAD~1
# or if you do not remember exactly
# in which commit it is, you might use
git rm --cached file
# For a pushed commit
# The proper way of removing
# files from the repository history is using git filter-branch. That is,
git filter-branch --index-filter 'git rm --cached file' HEAD
Git remove tags
# You just need to push an 'empty' reference to the remote tag name:
git push origin :tagname
# Or, more expressively,
# use the --delete option (or -d if your git version is older than 1.8.0):
git push --delete origin tagname
#If you also need to delete the local tag, use:
git tag --delete tagname
Sources
Stackoverflow1
Stackoverflow2
Stackoverflow3
No comments:
Post a Comment