Git常用命令

来源:互联网 发布:java打包 编辑:程序博客网 时间:2024/06/06 08:57

1.  获取帮助

 $ git help <verb>       //获取在线帮助

 $ git <verb> --help    //获取在线帮助

 $ git <vert> -h           //控制台中获取帮助

eg: git help branch


2.  查看本地分支对应的远程分支 [print the name of the upstream branch]

 $ git branch -vv


3. 创建分支/切换分支

 $ git branch xxx     //创建

 $ git checkout xxx  //切换


4. 取回更新

 $ git pull origin xxx  //取回origin主机的xxx分支


5. 提交到索引中

$ git add -u  //-u add to index only files modified or deleted and not those created


6. 提交

$ git commit -m '提交信息’


7. push 到远程

$ git push origin <local branch name>


8. 查看提交记录

$ git log

$ git log -p -2   //-p 选项展开显示每次提交的内容差异,用 -2 则仅显示最近的两次更新


9. 撤销本地未add、commit的所有修改

$ git reset --hard 




0 0
原创粉丝点击