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 ...
随机推荐
- Kuratowski's and Wagner's theorems
w https://en.wikipedia.org/wiki/Planar_graph The Polish mathematician Kazimierz Kuratowski provided ...
- jQuery改变CSS使DIV显示
HTML: <div id="mazey" style="display:none;">www.mazey.net</div> jQue ...
- MySql 批处理
1. 批处理 批处理只针对更新(增,删,改)语句. MySql 的批处理默认是关闭的, 需要在 url 中配置参数: jdbc:mysal://localhost:3306/mydb1?rewrite ...
- 解决Raize日历控件显示的问题
解决Raize日历控件显示的问题 近自己的程序被测试人员发现一个小问题,就是程序中的日历选择框,显示中的“星期一.星期二....”都显示成了“星.....”,我自己看了代码,原来是raize的控件问题 ...
- 【25】session练习
#用登录练习session html1为首页,html2为登录页面 def session1(request): uname=request.session.get('myname','请登录') # ...
- 设计线程安全的类 VS 发布线程安全的对象
一.设计线程安全的类 步骤: 找出构成对象状态的所有变量 找出约束状态变量的不变性条件 建立对象状态的并发访问策略 1.在现有的线程安全类中添加功能 (1)重用能减低工作量和提高正确性 (2)如果底层 ...
- 011-git-将tag推送到远端
1.将tag推送到远端 在使用TortoiseGit过程中,push推送过程中,选择include tag,远端就有次分支.
- 隐马尔可夫模型(hidden Markov model,HMM)
定义: 隐马尔科夫模型是关于时序的概率模型,描述由一个隐藏的马尔可夫链随机生成不可观测的状态随机序列,再由各个状态生成一个观测而产生观测随机序列的过程. 隐马尔科夫模型由初始概率分布.状态转移概率分布 ...
- Bootstrap入门教程
资料来源: http://www.cnblogs.com/ventlam/archive/2012/05/28/2520703.html 1.全局样式:Bootstrap要求html5的文件类型,所以 ...
- 小程序 height100% Android ios上的不同表现
Android还是按原图显示 ios,会完全覆盖