GIt上传本地项目方法

来源:互联网 发布:python怎么保存文件 编辑:程序博客网 时间:2024/06/07 23:35

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.gitgit 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 initReinitialized existing Git repository in C:/Users/lenovo/.git/.git/$ git commit -m '第一次提交'On branch masterYour branch is up to date with 'origin/master'.Changes not staged for commit:        modified:   testGIT.txtUntracked 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.gitfatal: remote origin already exists.$ git remote rm origin$ git remote add origin  https://github.com/Liumce/Car.git$ git push origin masterEverything up-to-date$ $ git remote -vbash: $: command not found$ git remote -vorigin  https://github.com/Liumce/Car.git (fetch)origin  https://github.com/Liumce/Car.git (push)$ git branch* master$ git initReinitialized existing Git repository in C:/Users/lenovo/.git/.git/$ git commit -m '第一次提交'On branch masterChanges not staged for commit:        modified:   testGIT.txtUntracked files:        Car/no changes added to commit(还是一样的问题)$ git remote add origin  https://github.com/Liumce/Car.gitfatal: remote origin already exists.$ git remote rm origin$ git remote add origin  https://github.com/Liumce/Car.git$ git pull origin masterFrom https://github.com/Liumce/Car * branch            master     -> FETCH_HEAD * [new branch]      master     -> origin/masterAlready up to date.$ git push origin masterEverything up-to-date$ git remove -vgit: 'remove' is not a git command. See 'git --help'.The most similar command is        remote$ git remote -vorigin  https://github.com/Liumce/Car.git (fetch)origin  https://github.com/Liumce/Car.git (push)$ git branch* master$ git initReinitialized existing Git repository in C:/Users/lenovo/.git/.git/$ git addNothing specified, nothing added.Maybe you wanted to say 'git add .'?$ git init git addusage: git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>]$ git initReinitialized 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.gitfatal: remote origin already exists.$ git push origin masterCounting 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


原创粉丝点击