DevilKing's blog

冷灯看剑,剑上几分功名?炉香无需计苍生,纵一穿烟逝,万丈云埋,孤阳还照古陵

0%

10 Git problems

原文链接

git checkout — 这样子废弃掉本地的修改

undo local commit

1
2
git reset HEAD~2        # undo last two commits, keep changes
git reset --hard HEAD~2 # undo last two commits, discard changes

Remove a file from git without removing it from your file system

1
2
git reset filename          # or git rm --cached filename
echo filename >> .gitingore # add it to .gitignore to avoid re-adding it

git-amend 操作可以对commit message进行amend操作

Clean up local commits before pushing

1
2
3
4
git rebase --interactive 
# if you didn't specify any tracking information for this branch
# you will have to add upstream and remote branch information:
git rebase --interactive origin branch