1. 程式人生 > >git 上傳本地專案到Github

git 上傳本地專案到Github

首先是本地倉庫的初始化

[email protected] MINGW64 /e/SpringSessionGit

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

第二步檢視本地機器生成的祕鑰是否存在你的github中
[email protected] MINGW64 /e/SpringSessionGit (master)
$ ssh -T [email protected]
Hi BlueCatJava1991! You've successfully authenticated, but GitHub does not provi       de shell access.

第三步設定你 的github的使用者名稱
[email protected]
MINGW64 /e/SpringSessionGit (master)
$ git config --global user.name "BlueCatJava1991"

第三步設定你 的github的郵箱
[email protected] MINGW64 /e/SpringSessionGit (master)

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

第四步設定你的遠端倉庫的地址 強調一點這個倉庫你必須在github上建立了                             

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

第五步新增README檔案  但是沒有成功
[email protected] MINGW64 /e/SpringSessionGit (master)
$ git add README
fatal: pathspec 'README' did not match any files


[email protected]
MINGW64 /e/SpringSessionGit (master)
$ gitt add README
bash: gitt: command not found


[email protected] MINGW64 /e/SpringSessionGit (master)
$ git add README
fatal: pathspec 'README' did not match any files

第六步push程式碼到github 沒有成功
[email protected] 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'


[email protected] 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'


[email protected] 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遠端程式碼到本地 
[email protected] 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

第八步繼續提交 發現還是有問題
[email protected] MINGW64 /e/SpringSessionGit (master)
$ git push origin master
Everything up-to-date


[email protected] MINGW64 /e/SpringSessionGit (master)
$ ^C

第九步檢視版本  發現是master
[email protected] MINGW64 /e/SpringSessionGit (master)
$ git remote -v
origin  [email protected]:BlueCatJava1991/springSessionShare.git (fetch)
origin  [email protected]:BlueCatJava1991/springSessionShare.git (push)


[email protected] MINGW64 /e/SpringSessionGit (master)
$ git branch
* master

第十步提交  命令 錯了
[email protected] MINGW64 /e/SpringSessionGit (master)
$ commit
bash: commit: command not found

第十一步提交  提示沒有add
[email protected] MINGW64 /e/SpringSessionGit (master)
$ git commit
On branch master
Untracked files:
        springBoot-springSession/


nothing added to commit but untracked files present

第十二步提交  那就add 所有了 好像可以了
[email protected] 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.

第十三提交  發現不行  喔   再看看提示  發現 要一個值
[email protected] 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)



第十四步  可以了 發現這個提交資訊是備註資訊  
[email protected] 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了 百分之百了
[email protected] 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