Some frequent operation of the git

来源:互联网 发布:av马赛克去除软件mac 编辑:程序博客网 时间:2024/05/21 19:38
  • delete the modification of the workspace:
git checkout -- <filename>
  • hard roll back the code version,it will not store your modification:
git reset --hard <commit id>
  • soft roll back the code and will take your modification to the workspace:
git reset --mixed <commit id>
  • roll back the remote branch:
##First make you local branch to the node you want,then push force to the remotegit reset --hard <commit id>git push origin HEAD --force
  • create a new local branch:
git checkout -b <local branch name>
  • create a remote branch with the same name of the local:
git push origin <your Branch Name>:<your Branch Name>
  • set the up-stream of the branch:
git branch --set-upstreamto=<remote branch name>
  • roll back some file to a node you want:
git checkout <commit id> -- <file1/to/restore>
原创粉丝点击