git init //把当前目录变成git可以管理的仓库

git add. //把文件添加到版本库中,使用命令 git add .添加到暂存区里面去,不要忘记后面的小数点“.”,意为添加文件夹下的所有文件(夹)。

git commit -m “描述内容” //提交到主分支

git commit -am "描述" //提交且添加注释

git remote add origin master 远程仓库地址 //本地仓库和远程仓库连接起来

git pull origin master //拉取代码至本地

git push -u origin master -f //提交至远程仓库,参数-f 强制上传,这样会使远程修改丢失,一般是不可取的,首次提交可用;参数-u set-upstream 一般同时存在两个远程仓库才会用到

常用git命令

git clone 远程仓库地址 //clone到本地

git branch 查看本地分支

git branch -a 查看所有分支(本地和远程分支)

git branch -r 查看远程分支

git status 查看当前状态,可以查看文件是否提交

git branch rosa1700(分支名) 创建本地分支

git push origin rosa1700 提交至远程且同步本地分支至远程

###

删除远程仓库的目录或文件

1、本地删除文件

2、然后再次提交

Ps:每次提交内容至远程仓库,都需要执行

git add .

git commit -am “描述”

git push origin master

创建本地分支:

git branch 本地分支name

切换本地分支:

git checkout newstable(分支名)

posted on 2018-06-27 15:34  rosa2015  阅读(113)  评论(0编辑  收藏  举报