将本地文件上传到远程git服务器
来源:互联网 发布:c语言编程实战宝典 编辑:程序博客网 时间:2024/05/18 03:51
1、(先进入项目文件夹)通过命令 gitinit 把这个目录变成git可以管理的仓库
git init
2、把文件添加到本地版本库中,使用命令git add 文件;添加到暂存区里面去,如果后面接小数点“.”,意为添加文件夹下的所有文件
git add .
3、用命令 git commit告诉Git,把文件提交到仓库。引号内为提交说明
git commit -m 'first commit'
4、关联到远程库
git remote add origin 你的远程库地址
如:
git remote add origin git@192.168.31.130:/srv/sample.git
如果上面步骤写错了:则
git remote rm origin //删除origin
git remote add origin git@git.oschina.net:yourname/demo.git //重新添加origin
5、获取远程库与本地同步合并(如果远程库不为空必须做这一步,否则后面的提交会失败)
git pull --rebase origin master
6、将最新的修改推送到远程仓库:gitpush -u origin master
备注:origin:远程仓库名字;master:分支
注意:我们第一次push的时候,加上-u参数,Git就会把本地的master分支和远程的master分支进行关联起来,我们以后的push操作就不再需要加上-u参数了
如果出现类似下面内容:
Username for 'https://github.com': shiren1118
Password for 'https://shiren1118@github.com':
To https://github.com/shiren1118/iOS_code_agile.git
![rejected] master -> master(non-fast-forward)
error: failed to push some refs to'https://github.com/shiren1118/iOS_code_agile.git'
hint: Updates were rejected because the tip of yourcurrent branch is behind
hint: its remote counterpart. Merge the remote changes(e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push--help' for details.
则输入命令:git push -u origin master –f即可搞定问题
如果从在git服务器所在主机上的其他账户获取git服务器上面文件,则直接用
gitclone + git仓库的路径,即:gitclone /srv/sample.git/
- 将本地文件上传到远程git服务器
- git将本地文件上传到远程仓库
- 将本地文件上传到远程git仓库
- git 首次将本地文件上传到服务器和git常用命令
- 怎么将本地文件上传到远程git仓库
- 将本地文件上传到远程FTP服务器和从远程FTP服务器下载文件到本地
- 将本地文件上传到远程仓库
- git 创建远程仓库并将本地文件上传到远程仓库
- php本地文件上传到远程服务器
- 使用TortoiseGit上传本地文件到远程服务器
- 把本地文件git到远程服务器
- 使用git将本地文件上传到github
- git将本地文件上传到github
- 如何将本地文件复制到远程服务器
- 如何将本地文件复制到远程服务器
- 将本地文件上传到服务器上
- 如何将本地文件上传到windows服务器
- Mac将本地文件上传到服务器上
- 移动游戏市场的高速发展
- 粘滞位——文件/目录的删除和移动
- LabVIEW 的动态调用
- slot分发
- js打印页面
- 将本地文件上传到远程git服务器
- 设计模式六大原则-里氏替换原则
- 归并排序 原理和java实现
- 前端面试题共享
- C++ 内联函数inline
- 减少if-else使用
- 阿里云 ECS Linux系统无法SSH免密码登陆的处理办法
- 如何判断闰年
- web前端面试水平垂直居中详解