Git常用命令

来源:互联网 发布:java 获取整数的位数 编辑:程序博客网 时间:2024/06/05 07:21

创建并绑定本地分支和远程分支 git checkout -b branchname origin/branchname

删除分支 git branch -D branchname

切换分支 git checkout branchname

显示分支 git branch

创建分支 git branch branchname

显示所有分支 git branch -a

拉取远程代码 git pull

克隆代码 git clone 地址.git

添加到本地缓存区 git add filename

提交到本地仓库 git commit -m “modified message”

查看状态 git status

查看工作区和版本库里面最新版本的区别 git diff HEAD — filename

撤销工作区的修改(从版本库里恢复文件) git checkout — filename

删除文件 git rm filename

版本回退 git reset –hard 3628164

显示日志 git log

在一行内显示日志 git log –pretty=oneline

忽略.idea文件
echo.idea>>.gitignore git rm -r –cached .idea
gitadd.gitignore git commit -m ‘(some message stating you added .idea to ignored entries)’
$ git push

原创粉丝点击