您的位置:首页 > 编程语言

repo和Git 使用记录

2017-02-14 12:04 579 查看

本地:

###步骤:
1、创建文件夹 HelloWorld,进入目录
2、新项目初始化:git init
3、将当前目录下所有文件添加到缓冲区:git add .
4、将缓冲区代码提交到本地仓库: git commit . -m '注释'


远程:

###步骤:
1、在github上创建一个仓库
2、将远程仓库代码下载到本地:
git clone https://github.com/ribachua/ribachua.github.io.git 3、设置添加远程仓库地址:
git remote add github 'https://github.com/ribachua/ribachua.github.io.git'
4、初始化
git init
5、添加
git add .
6、提交
git commit -m 'first commit'
7、将本地主分支推到远程(如无远程主分支则创建,用于初始化远程仓库)
git push -u origin master


其他

查看当前文件/分支状态

1、查看当前文件状态
git status


查看分支:

1 查看本地分支
git branch
2 查看远程分支
git branch -r


创建新分支:

///branchName:分支名称
1 创建本地分支(建立分支后,仍停留在当前分支):
git branch branchName
2 创建分支后切换到新分支
git checkout branchName


提交分支:

1、提交到本地的当前分支
git commit . -m '注释'
2、提交到远程分支
git commit . -m '注释'
git push origin branchName:branchName
2 如果想把本地的某个分支mybranch提交到远程仓库,并作为远程仓库的master分支
git push origin mybranch:master


删除分支:

1、删除远程分支
git push origin :branchName
2、删除本地分支,强制删除用-D
git branch -d branchName


合并分支

1、将分支branchName和当前所在分支合并
git merge branchName


标记tag

1、对当前分支打tag:
git tag tagContent
2、然后push到远程即可:
git push origin branchName:branchName


repo

查看可切换分支

1.cd .repo/manifests
2.git branch -a | cut -d / -f 3


拉取代码

1.repo init
2.repo sync


查看当前的分支

1.repo branches


切换所有库到某个分支

1.repo forall  -c git checkout branchName


删除所有库的某个分支

1.repo forall  -c git branch -D branchName


……

……

……

待续
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  github git repo