git 常用操作

Git常用操作

客户端下载

git windows版下载镜像:https://npm.taobao.org/mirrors/git-for-windows/

 

常用命令

git branch 查看本地分支列表

git branch -r 查看远程分支

git stash 将工作空间临时保存

git stash save "msg"  将工作空间临时保存并且添加描述信息

git stash apply 从临时保存中取出最近一次保存并使用

git stash list 查看已临时保存修改列表

git stash apply n 从临时保存中取出编号为n的保存并使用

 git branch -a 查看分支列表和详情

git remote -v 查看分支对应的远程路径

git diff --staged 查看

git clone url 从url指定的仓库位置复制内容到本地

git pull 从远程仓库拉取最新代码并合并

git reflog 查看历史操作日志

git fsck 列出所有add过的文件, 通过git show 找回add过,被误删除的文件。

 

删除分支

git branch -d branchToDel       删除本地分支,前提是先checkout到其他分支,否则不允许删除

git push origin --delete branchToDel   删除远程分支

 

分支合并

git merge target-branch   将target-branch合并到当前分支

 

打tag

git tag -a tag_name commit_id -m "1.第一行
>> 第二行
>> 第三行"
推送tag到远程仓库:git push origin tag_name

 

切换仓库地址

查看本地当前指向的远程库地址:

git remote -v 

git remote set-url origin http://localhost:18080/test/test.git  修改仓库地址

git push origin HEAD --force  将本地工程强制推送到远程空仓库,如果远程版本比本地更新,需要pull,合并后推送

 

posted on 2019-11-25 10:28  哼着歌啦啦啦  阅读(125)  评论(0编辑  收藏  举报