git 里面遇到的问题
第一步:建立git仓库(本地)
cd到你的本地项目根目录下,执行git命令
git init
第二步:将项目的所有文件添加到仓库中
git add .
如果想添加某个特定的文件,只需把.换成特定的文件名即可
第三步:将add的文件commit到仓库
git commit -m "注释语句"
第四步:去github上创建自己的Repository,创建页面如下图所示:
第五步:重点来了,将本地的仓库关联到github上
git remote add origin https://github.com/Interesting6/my_numeral_calculations.git
后面的https链接地址换成你自己的仓库url地址
第六步:上传github之前,要先pull一下,执行如下命令:
git pull origin master
敲回车后,会执行输出类似如下

第七步,也就是最后一步,上传代码到github远程仓库
git push -u origin master
执行完后,如果没有异常,等待执行完就上传成功了,中间可能会让你输入Username和Password,你只要输入github的账号和密码就行了
-----------------------------------------------------------------------------------------------------------------------------------
遇到的问题,有时我只需要上传一个文件,而这个文件在GitHub上还没有目录,在刚刚仓库(本地)的目录下打开git bash:
Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
$ git add ./functionroot/iteration_method.py
# 添加该functionroot目录下的文件iteration_method.py
然后提交一下
Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
$ git commit -m "solving nonlinear function in iteration method"
[master c08aed3] solving nonlinear function in iteration method
1 file changed, 133 insertions(+)
create mode 100644 functionroot/iteration_method.py
然后push就出错了:
Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
$ git push -u origin master
To https://github.com/Interesting6/my_numeral_calculations.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/Interesting6/my_numeral_calculations.git'
hint: Updates were rejected because the remote contains work that you do # 更新被拒绝,因为远程包含本地没有的工作。
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
试了一下网上说的:
Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
$ git pull --rebase origin master
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.
也没用,然后试了下下面的:
You may want to first merge the remote changes (e.g., 'git pull') before pushing again.
在再次推送之前,您可能需要首先合并远程更改(例如,“git pull”)。
that is:
git pull
# Fix any merge conflicts, if you have a `README.md` locally
git push -u origin master
输入下面就通过vim进入一个文件内,我直接保存退出
Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/Interesting6/my_numeral_calculations
8fd4a0c..31dacac master -> origin/master
* [new branch] Interesting6-solve_linear_equations -> origin/Interesting6-solve_linear_equations
Merge made by the 'recursive' strategy.
Interpolation.html => Interpolation/Interpolation.html | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Interpolation.html => Interpolation/Interpolation.html (100%)
然后再push一下就好了,很迷。。
Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
$ git push -u origin master
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 1.61 KiB | 0 bytes/s, done.
Total 6 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
To https://github.com/Interesting6/my_numeral_calculations.git
31dacac..8447fed master -> master
Branch master set up to track remote branch master from origin.
-------------------------------------------------------------------------------------------
下面是我对文件里面的README.md进行更新:
Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
$ git add README.md Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
$ git commit -m "update readme"
[master 3db337d] update readme
1 file changed, 7 insertions(+), 2 deletions(-) Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
$ git push -u origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 433 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/Interesting6/my_numeral_calculations.git
8447fed..3db337d master -> master
Branch master set up to track remote branch master from origin. Mr.Black@DESKTOP-4Q3FM6F MINGW64 /e/Sublime/python/calculate (master)
就好了。
git 里面遇到的问题的更多相关文章
- Git 子模块 - submodule
有种情况我们经常会遇到:某个工作中的项目需要包含并使用另一个项目. 也许是第三方库,或者你 独立开发的,用于多个父项目的库. 现在问题来了:你想要把它们当做两个独立的项目,同时又想在 一个项目中使用另 ...
- Git 在团队中的最佳实践--如何正确使用Git Flow
我们已经从SVN 切换到Git很多年了,现在几乎所有的项目都在使用Github管理, 本篇文章讲一下为什么使用Git, 以及如何在团队中正确使用. Git的优点 Git的优点很多,但是这里只列出我认为 ...
- Git与Repo入门
版本控制 版本控制是什么已不用在说了,就是记录我们对文件.目录或工程等的修改历史,方便查看更改历史,备份以便恢复以前的版本,多人协作... 一.原始版本控制 最原始的版本控制是纯手工的版本控制:修改文 ...
- Git Bash的一些命令和配置
查看git版本号: git --version 如果是第一次使用Git,你需要设置署名和邮箱: $ git config --global user.name "用户名" $ gi ...
- 在Ubuntu 16.10 安装 git 并上传代码至 git.oschina.net
1. 注册一个账号和创建项目 先在git.oschina.net上注册一个账号和新建一个project ,如project name 是"myTest". 2.安装git sudo ...
- 史上最详细git教程
题外话 虽然这个标题很惊悚,不过还是把你骗进来了,哈哈-各位看官不要着急,耐心往下看 Git是什么 Git是目前世界上最先进的分布式版本控制系统. SVN与Git的最主要的区别 SVN是集中式版本控制 ...
- [版本控制之道] Git 常用的命令总结(欢迎收藏备用)
坚持每天学习,坚持每天复习,技术永远学不完,自己永远要前进 总结日常开发生产中常用的Git版本控制命令 ------------------------------main-------------- ...
- 【解决方案】Myeclipse 10 安装 GIT 插件 集成 步骤 图解
工程开发中,往往要使用到集成GIT ,那么下面说说插件安装步骤 PS:以Myeclipse 10 为例,讲解集成安装步骤. ----------------------main------------ ...
- git 命令
切换仓库地址: git remote set-url origin xxx.git切换分支:git checkout name撤销修改:git checkout -- file删除文件:git rm ...
- git亲测命令
一.Git新建本地分支与远程分支关联问题 git checkout -b branch_name origin/branch_name 或者 git branch --set-upstream bra ...
随机推荐
- 1119 机器人走方格 V2(组合)
1119 机器人走方格 V2 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 M * N的方格,一个机器人从左上走到右下,只能向右或向下走.有多少种不同的走法?由于 ...
- linux解压war包
可以用unzip命令 unzip project.war -d project 这样就在当前目录下解压project.war到project目录里面,参数-d的意思是创建project目录 附:unz ...
- 关于git 提交到分支
想必大家对于github并不陌生,但是有时候我们提交到github上的页面,想将静态的页面展示给别人看,所以这个时候,需要创建一个gh-pages的分支,然后利用 https://you github ...
- RabbitMQ中Queue详细介绍
新建队列 新建Queue时有很多参数,都代表什么含义,在这里解释一下: 前述:Rabbit版本为3.7.6 ErLang 版本为 21.0.1 Name 必填项,队列的名字,建议格式可以为多个字段,表 ...
- websocket Session 不支持序列化
这是我本来的打算,把socket session 进行序列化分布式存储! 呵呵 然而现实很残酷,这b东西不支持序列化! 解决办法:
- Extract, Transform, Load
w https://en.wikipedia.org/wiki/Extract,_transform,_load
- Java中volatile关键字实现原理
原文地址http://www.cnblogs.com/xrq730/p/7048693.html,转载请注明出处,谢谢 前言 我们知道volatile关键字的作用是保证变量在多线程之间的可见性,它是j ...
- .Net自带ChartControl报错:Auto interval does not have proper value
出现这个错误的原因是我们给ChartControl同时设置了Minimum和Maxmum的值,而这两个值又恰好相等. chart.ChartAreas[0].AxisY.Minimum=min; ch ...
- 正确使用索引(sql优化),limit分页优化,执行计划,慢日志查询
查看表相关命令 - 查看表结构 desc 表名- 查看生成表的SQL show create table 表名- 查看索引 show index from 表名 使用索引和不使用索引 由 ...
- Symfony 一些介绍
Symfony 一些介绍: 路由:能限制 hostname,这就让有大量公共功能的网站可以共用一套代码:URI 识别支持 Reg 检测,让 url 能定义的随心所欲:支持前缀,import,便于模块化 ...