首页 > 学院 > 开发设计 > 正文

Git常用命令总结

2019-11-06 06:39:42
字体:
来源:转载
供稿:网友

仓库初始化

新建仓库:git init

拷贝远程仓库到本地:git clone https://github.com/wispyoureyes/myblog.git(远程仓库地址)

本地仓库连接远程仓库:git remote add origin https://github.com/wispyoureyes/myblog.git(远程仓库地址)

文件改动

将工作区文件改动添加到本地暂存区:git add < file > 将工作区所有改动添加到暂存区:git add .

第一次提交本地代码到远程master:git push -u origin master(之后都用git push)

分支相关

新建分支:git branch new_branch 新建分支并切换到新分支上: git checkout -b new_brnach

删除远程分支(删除master前需要先将主分支设置为其他分支):git push -delete origin master 删除本地分支: git branch -d master

查看本地分支:git branch 查看包括远程分支的所有分支:git branch -a

回滚历史版本

回滚历史版本到新分支上:git branch new_branch HEAD(SHA)


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表