git 推送基本操作
2017-04-11 19:45
274 查看
本文介绍使用命令行创建远程仓库,编写本地文件,添加 .gitignore 文件,并提交到远程仓库:
# 使用命令行创建 git 的远程仓库
curl -u 'degawong' https://api.github.com/user/repos -d '{"name":"my-repos"}'
在大括号内的 { 参数:数值 } 对中参数有很多,都可以手动设置:
# 官网给出的参数解释如下所示 :
{
"name": "degawong",
"description": "This is your first repository",
"homepage": "https://github.com",
"private": false,
"has_issues": true,
"has_projects": true,
"has_wiki": true
}
# 一般使用时,可以只使用上述几个参数,还有其他的无关紧要的参数可以选择默认
# 官网给的例子中, "private" 属性选择了私有,这个是需要缴费的,所以这个参数
# 需要修改为 false
此时,在 github 上就生成了名字为 my-repos 得远程仓库:
# 新建目录 my-repos
mkdir my-repos
# 进入到 my-repos 目录
cd my-repos
# 初始化 git 仓库
git init
# 添加远程仓库连接
git remote add origin https://github.com/degawong/my-repos.git # 编写一个项目(opencv)
……
# 添加 .gitignore 文件
touch .gitignore
# 编写 .gitignore 文件 去除自动生成得文件夹与中间文件等
vi .gitignore
# 添加本目录下的所有文件
git add .
# 提交添加的所有文件
git commit -m"it's a curl repos solution"
# 提交到远程仓库(首次提交添加 -u)
git push -u origin master
仓库名字可能忘记或者写错,或者只是想改变一个连接的远程仓库,此时可以使用“
# 断开当前的远程 repos 连接
git remote rm <name of repos>
git add origin master <name of repos>
# 还有这种方式也可以
git remote set-url origin url
还有,要注意的是,建立的 git repos 名称有两种命名方式:
# 分别为 ssh 与 https 方式,根据个人爱好使用
git@github.com/degawong/my-repos.git https://github.com/degawong/my-repos.git 我的一个使用命令行窗口建立的远程 repos 的项目链接为 :
https://github.com/degawong/curl-repos
# 使用命令行创建 git 的远程仓库
curl -u 'degawong' https://api.github.com/user/repos -d '{"name":"my-repos"}'
在大括号内的 { 参数:数值 } 对中参数有很多,都可以手动设置:
# 官网给出的参数解释如下所示 :
{
"name": "degawong",
"description": "This is your first repository",
"homepage": "https://github.com",
"private": false,
"has_issues": true,
"has_projects": true,
"has_wiki": true
}
# 一般使用时,可以只使用上述几个参数,还有其他的无关紧要的参数可以选择默认
# 官网给的例子中, "private" 属性选择了私有,这个是需要缴费的,所以这个参数
# 需要修改为 false
此时,在 github 上就生成了名字为 my-repos 得远程仓库:
# 新建目录 my-repos
mkdir my-repos
# 进入到 my-repos 目录
cd my-repos
# 初始化 git 仓库
git init
# 添加远程仓库连接
git remote add origin https://github.com/degawong/my-repos.git # 编写一个项目(opencv)
……
# 添加 .gitignore 文件
touch .gitignore
# 编写 .gitignore 文件 去除自动生成得文件夹与中间文件等
vi .gitignore
# 添加本目录下的所有文件
git add .
# 提交添加的所有文件
git commit -m"it's a curl repos solution"
# 提交到远程仓库(首次提交添加 -u)
git push -u origin master
仓库名字可能忘记或者写错,或者只是想改变一个连接的远程仓库,此时可以使用“
# 断开当前的远程 repos 连接
git remote rm <name of repos>
git add origin master <name of repos>
# 还有这种方式也可以
git remote set-url origin url
还有,要注意的是,建立的 git repos 名称有两种命名方式:
# 分别为 ssh 与 https 方式,根据个人爱好使用
git@github.com/degawong/my-repos.git https://github.com/degawong/my-repos.git 我的一个使用命令行窗口建立的远程 repos 的项目链接为 :
https://github.com/degawong/curl-repos
相关文章推荐
- Git学习系列之Git基本操作推送项目(图文详解)
- git学习三 git基本操作
- Git基本概念及操作(1)
- Git基本命令行操作
- git学习 #2:git基本操作
- git学习 #2:git基本操作
- 一步一步学习Git(2)——Git基本操作
- my project 中git使用过程(基本操作流程)
- Git基本操作
- git简介、安装、基本操作——Git折腾小记
- git学习 #2:git基本操作
- Git基本概念及操作(2)
- git一些基本操作备忘
- Git操作流程,基本命令演示
- Git 基本操作
- pro git 阅读笔记1 基本操作
- git 基本操作与规范流程
- windows下GIT使用记录--01基本操作
- git基本操作
- my project 中git使用过程(基本操作流程)