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 ...
随机推荐
- outlook撤回已发送邮件
官方教程参考: https://support.office.com/zh-cn/article/%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6%E5%90%8E%E6%92 ...
- SharePoint服务器端对象模型 之 对象模型概述(Part 1)
在一个传统的ASP.NET开发过程中,我们往往会把开发分为界面展现层.逻辑业务层和数据访问层这三个层面.作为一个应用开发平台,SharePoint是微软在直观的开发能力和自由的扩展能力之间,取到的一个 ...
- JFrame上添加、删除Jpanel后动态显示界面问题
JFrame中动态添加或者删除JPanel后总是不正确显示需要的界面问题: 1.删除panel后还是显示之前的界面,新删除的panel在界面上并没有被删除: 2.删除panel1后添加新的panel2 ...
- 基于websocket搭建简易群聊
1.前端HTML <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset=&qu ...
- Python __setitem__()、__getitem__()、__delitem__()
转载:http://blog.csdn.net/xhw88398569/article/details/48690163 __xxxitem__:使用 [''] 的方式操作属性时被调用 __setit ...
- Unity3D游戏开发从零单排(六) - 人物运动及攻击连击
提要 今天要实现的是一个简单人物控制器. 包括用w,a,s,d来控制人物上下左右跑动,鼠标左击发出连招,都是基于老的lagacy的动画.尽管unity3d自带有charactorcontroller, ...
- ubuntu16.04的下载地址
官网不推荐 https://www.ubuntu.com/download 阿里云开源镜像站 http://mirrors.aliyun.com/ubuntu-releases/16.04/ 浙江大学 ...
- 剑指offer 面试4题
面试4题: 题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数. 解题代码一:二 ...
- Way to Git
最近在学习Git,我先后在CentOS6.4, Ubuntu12.04, Windows7上安装Git,遇到的问题比较多的是在CentOS上的安装,Ubuntu和Windows7上的安装相对比较简单, ...
- LeetCode:罗马数字转整数【13】
LeetCode:罗马数字转整数[13] 题目描述 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 10 ...