您的位置:首页 > 其它

GIt上传本地项目方法

2017-12-20 10:29 295 查看

GIt上传本地项目方法

关于在github上的安装记录:

注册

登录

创建

配置

GUI

Bash

命令行上传

报错

解决方案

感谢

注册

首先,先注册github账号:https://github.com/

登录

看这里:

当然,作为一位认真的程序员(媛),这个功能建议不用,看英文利用自己编程原生理解。

登录你的账号: (成功后)





创建



点击它,将开启你的github编程生涯!!!



你要去git官网下载程序:

https://git-scm.com/downloads

配置

Bash 命令

在安装完成的GIT 中,最后一步,你需要在Git里面有自己的Github信息,所以:

http://www.runoob.com/git/git-install-setup.html

该Git 安装手册中有一个最后一步,如下:





(这是百度经验做出来的文件效果)

这里:

https://jingyan.baidu.com/album/c146541384b0ab0bfcfc4ca3.html?picindex=5

参考这个百度经验链接,但因为第5步所以换了方式

但是.git 这个文件依然存在,没有被删除

这样在之后你搭建的时候 再登录一次即可。

点开你的.git 所在目录 ,里面的样子是:



> 之前用 GUI 未成功上传,现在换用命令行(Bash)的方式:


你可以点击空白出 右键 弹出GIT BASH Here ,这时,你就可以点击它了。



命令行上传

命令行代码:

例如我的小汽车项目,我将本地做好的Car  项目包复制粘贴在.git 文件下,右键点击 git bash ,进入命令行编辑。
git init
git commit -m 'Car'
git remote add origin https://github.com/Liumce/Car.git git push origin master

如果执行git remote add origin https://github.com/Liumce/Car.git 如果出现错误,
remote origin already exists

则执行以下语句::
git remote rm origin

再往后执行git remote add origin https://github.com/Flowerowl/stumansys.git 即可。
在执行git push origin master时,报错:

failed to push som refs to ....
则执行以下语句:
git pull origin master

最后报了错:

$ git init
Reinitialized existing Git repository in C:/Users/lenovo/.git/.git/

$ git commit -m '第一次提交'
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
modified:   testGIT.txt

Untracked files:
Car/

no changes added to commit

$ git remote add origin  https:// fatal: remote origin already exists.

$ git remote add origin  https://github.com/Liumce/Car.git fatal: remote origin already exists.

$ git remote rm origin

$ git remote add origin  https://github.com/Liumce/Car.git 
$ git push origin master
Everything up-to-date

$ $ git remote -v
bash: $: command not found

$ git remote -v
origin  https://github.com/Liumce/Car.git (fetch)
origin  https://github.com/Liumce/Car.git (push)

$ git branch
* master

$ git init
Reinitialized existing Git repository in C:/Users/lenovo/.git/.git/

$ git commit -m '第一次提交'
On branch master
Changes not staged for commit:
modified:   testGIT.txt

Untracked files:
Car/

no changes added to commit
(还是一样的问题)

$ git remote add origin  https://github.com/Liumce/Car.git fatal: remote origin already exists.

$ git remote rm origin

$ git remote add origin  https://github.com/Liumce/Car.git 
$ git pull origin master
From https://github.com/Liumce/Car * branch            master     -> FETCH_HEAD
* [new branch]      master     -> origin/master
Already up to date.

$ git push origin master
Everything up-to-date

$ git remove -v
git: 'remove' is not a git command. See 'git --help'.

The most similar command is
remote

$ git remote -v
origin  https://github.com/Liumce/Car.git (fetch)
origin  https://github.com/Liumce/Car.git (push)

$ git branch
* master

$ git init
Reinitialized existing Git repository in C:/Users/lenovo/.git/.git/

$ git add
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?

$ git init git add
usage: git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>]

$ git init
Reinitialized existing Git repository in C:/Users/lenovo/.git/.git/

$ git add .
(此处空格 .)

$ git commit -m '第一次提交'
[master c223efb] 第一次提交
6 files changed, 429 insertions(+)
create mode 100644 Car/.classpath
create mode 100644 Car/.project
create mode 100644 Car/.settings/org.eclipse.jdt.core.prefs
create mode 100644 Car/bin/Car.class
create mode 100644 Car/src/Car.java

$ git remote add origin https://github.com/Liumce/Car.git fatal: remote origin already exists.

$ git push origin master
Counting objects: 12, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (12/12), 7.98 KiB | 454.00 KiB/s, done.
Total 12 (delta 0), reused 0 (delta 0)
To https://github.com/Liumce/Car.git 7bc721a..c223efb  master -> master

$


报错

你会发现没有上传进去,报错了(看系统给你的报错信息)分支错误

解决方案

这一步其实在报错代码里面 ,我已经写上了解决方法。

敲重点

github 用git bash上传项目 最后提示 Everything

up-to-date 但没传上去

所以在女朋友的帮助下:

解决方案如下:

http://github.mygreen.site/2017/12/08/20171208/

然后再回到自己的项目文件,get bash here

按照文档的步骤,在初始化之后,也就是 git init 之后,加上 git add .(此处有一个空格,一个点),然后依次按照步骤走,最后就上传成功啦!



感谢

感谢大佬:http://lazynight.me/2898.html

感谢对象:http://github.mygreen.site/2017/12/08/20171208/

附上这个小汽车的项目代码(java gui) :

https://github.com/Liumce/Car.git
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: