git 上传本地项目到Github

首先是本地仓库的初始化

341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit

$ git init
Initialized empty Git repository in E:/SpringSessionGit/.git/

第二步查看本地机器生成的秘钥是否存在你的github中
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ ssh -T [email protected]
Hi BlueCatJava1991! You've successfully authenticated, but GitHub does not provi       de shell access.

第三步设置你 的github的用户名
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git config --global user.name "BlueCatJava1991"

第三步设置你 的github的邮箱
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)

$ git config --global user.email "[email protected]"    

第四步设置你的远程仓库的地址 强调一点这个仓库你必须在github上创建了                             

341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git remote add origin [email protected]:BlueCatJava1991/springSessionShare.git

第五步添加README文件  但是没有成功
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git add README
fatal: pathspec 'README' did not match any files


341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ gitt add README
bash: gitt: command not found


341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git add README
fatal: pathspec 'README' did not match any files

第六步push代码到github 没有成功
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git push origin master
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:BlueCatJava1991/springSession       Share.git'


341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git push origin master
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:BlueCatJava1991/springSession       Share.git'


341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git push origin master
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:BlueCatJava1991/springSession       Share.git'

第七步pull远程代码到本地 
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git pull origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:BlueCatJava1991/springSessionShare
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master

第八步继续提交 发现还是有问题
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git push origin master
Everything up-to-date


341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ ^C

第九步查看版本  发现是master
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git remote -v
origin  [email protected]:BlueCatJava1991/springSessionShare.git (fetch)
origin  [email protected]:BlueCatJava1991/springSessionShare.git (push)


341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git branch
* master

第十步提交  命令 错了
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ commit
bash: commit: command not found

第十一步提交  提示没有add
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git commit
On branch master
Untracked files:
        springBoot-springSession/


nothing added to commit but untracked files present

第十二步提交  那就add 所有了 好像可以了
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git add .
warning: LF will be replaced by CRLF in springBoot-springSession/pom.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in springBoot-springSession/src/main/webapp       /WEB-INF/web.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in springBoot-springSession/src/main/webapp       /index.jsp.
The file will have its original line endings in your working directory.

第十三提交  发现不行  喔   再看看提示  发现 要一个值
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git commit -m
error: switch `m' requires a value
usage: git commit [<options>] [--] <pathspec>...


    -q, --quiet           suppress summary after successful commit
    -v, --verbose         show diff in commit message template


Commit message options
    -F, --file <file>     read message from file
    --author <author>     override author for commit
    --date <date>         override date for commit
    -m, --message <message>
                          commit message
    -c, --reedit-message <commit>
                          reuse and edit message from specified commit
    -C, --reuse-message <commit>
                          reuse message from specified commit
    --fixup <commit>      use autosquash formatted message to fixup specified co       mmit
    --squash <commit>     use autosquash formatted message to squash specified c       ommit
    --reset-author        the commit is authored by me now (used with -C/-c/--am       end)
    -s, --signoff         add Signed-off-by:
    -t, --template <file>
                          use specified template file
    -e, --edit            force edit of commit
    --cleanup <default>   how to strip spaces and #comments from message
    --status              include status in commit message template
    -S, --gpg-sign[=<key-id>]
                          GPG sign commit


Commit contents options
    -a, --all             commit all changed files
    -i, --include         add specified files to index for commit
    --interactive         interactively add files
    -p, --patch           interactively add changes
    -o, --only            commit only specified files
    -n, --no-verify       bypass pre-commit and commit-msg hooks
    --dry-run             show what would be committed
    --short               show status concisely
    --branch              show branch information
    --porcelain           machine-readable output
    --long                show status in long format (default)
    -z, --null            terminate entries with NUL
    --amend               amend previous commit
    --no-post-rewrite     bypass post-rewrite hook
    -u, --untracked-files[=<mode>]
                          show untracked files, optional modes: all, normal, no.        (Default: all)



第十四步  可以了 发现这个提交信息是备注信息  
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git commit -m "提交信息"
[master 3d79698] 提交信息
 13 files changed, 342 insertions(+)
 create mode 100644 springBoot-springSession/.classpath
 create mode 100644 springBoot-springSession/.project
 create mode 100644 springBoot-springSession/.settings/org.eclipse.core.resource       s.prefs
 create mode 100644 springBoot-springSession/.settings/org.eclipse.jdt.core.pref       s
 create mode 100644 springBoot-springSession/.settings/org.eclipse.m2e.core.pref       s
 create mode 100644 springBoot-springSession/.settings/org.eclipse.wst.common.pr       oject.facet.core.xml
 create mode 100644 springBoot-springSession/pom.xml
 create mode 100644 springBoot-springSession/src/main/java/com/ikejie/test/HttpS       essionConfig.java
 create mode 100644 springBoot-springSession/src/main/java/com/ikejie/test/Sampl       eController.java
 create mode 100644 springBoot-springSession/src/main/resources/application.prop       erties
 create mode 100644 springBoot-springSession/src/main/webapp/WEB-INF/web.xml
 create mode 100644 springBoot-springSession/src/main/webapp/index.jsp
 create mode 100644 springBoot-springSession/target/classes/application.properti       es

第十五步  提交代码了  ok了 百分之百了
341458@SHA-Q11210189 MINGW64 /e/SpringSessionGit (master)
$ git push origin master
Counting objects: 26, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (26/26), 5.46 KiB | 0 bytes/s, done.
Total 26 (delta 0), reused 0 (delta 0)
To github.com:BlueCatJava1991/springSessionShare.git
   aa8baf1..3d79698  master -> master

猜你喜欢

转载自blog.csdn.net/jiewenike/article/details/68060779