这篇文章详细讲解了如何生成 SSH,并链接到 GitHub,123.....
1. 如果你的 GitHub 里面没有仓库,就自己生成一个,如图所示
2. 如果你有自己仓库,想在电脑本地新建一个,你需要将 GitHub 的仓库地址复制下来,注意使用的是 ssh,如图所示,
3. 在电脑本地新建一个文件夹,将我们的远程仓库 clone 下来,
- 我是在d盘,test文件夹下面,直接右击选择git bash here
- MINGW32 /d/test
- 输入下面的命令
- $ git clone :Gabrielkaliboy/markdown.git
- git会返回下面的文字
- Cloning into 'markdown'...
- Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts.
- remote: Counting objects: 12, done.
- remote: Compressing objects: 100% (8/8), done.
- ), reused 11 (delta 0), pack-reused 0
- Receiving objects: 100% (12/12), 23.26 KiB | 0 bytes/s, done.
- Resolving deltas: 100% (1/1), done.
- Checking connectivity... done.
此时我们再去看我们的文件夹目录,已经顺利将文件 clone 到了本地
4. 我们切入下载下来的文件夹(markdown),进行一些操作,我们可以看到多了一个单词,master
- $ cd markdown
5. 我们往 markdown 文件夹里面放多个文件,然后查看一下当前的状态
- 在markdown里面新建文件里面,查看一下当前的状态
- $ git status
- git会给我们返回这个信息
- On branch master
- Your branch is up-to-date with 'origin/master'.
- Untracked files:
- (use "git add <file>..." to include in what will be committed)
- images/webDaily/
- "markdown\344\275\277\347\224\250\346\212\200\345\267\247.md"
- "\345\211\215\347\253\257\346\227\245\345\270\270\350\256\260\345\275\225.md"
- nothing added to commit but untracked files present (use "git add" to track)
6. 将多个文件同时提交到暂存区(或者将多个被修改的文件同时进行提交)
- $git add -A.
没有任何返回
7. 我们再次查看一下当前的状态
- 输入命令:
- $ git status
- git返回:
- On branch master
- Your branch is up-to-date with 'origin/master'.
- Changes to be committed:
- (use "git reset HEAD <file>..." to unstage)
- new file: images/webDaily/1.jpg
- new file: "markdown\344\275\277\347\224\250\346\212\200\345\267\247.md"
- new file: "\345\211\215\347\253\257\346\227\245\345\270\270\350\256\260\345\275\225.md"
8. 将暂存区的文件提交到 GitHub 分支
- -m右面是此次提交的信息说明,输入命令:
- $ git commit -m"提交新的文件"
- Git会给我们返回:
- [master eea6990] 提交新的文件
- 3 files changed, 111 insertions(+)
- create mode 100644 images/webDaily/1.jpg
- create mode 100644 "markdown\344\275\277\347\224\250\346\212\200\345\267\247.md"
- create mode 100644 "\345\211\215\347\253\257\346\227\245\345\270\270\350\256\260\345\275\225.md"
9. 再次查看当前的本地仓库状态
- 输入命令:
- $ git status
- Git返回的信息:
- On branch master
- Your branch is ahead of 'origin/master' by 1 commit.
- (use "git push" to publish your local commits)
- nothing to commit, working directory clean
他提示我们将分支提交到主分支
10 还没有结束,我们需要将我们的文件推送到分支
- 输入:
- $ git push -u origin master
- Git返回:
- Counting objects: 7, done.
- Delta compression using up to 2 threads.
- Compressing objects: 100% (6/6), done.
- Writing objects: 100% (7/7), 7.85 KiB | 0 bytes/s, done.
- Total 7 (delta 0), reused 0 (delta 0)
- To :Gabrielkaliboy/markdown.git
- cd8d69d..eea6990 master -> master
- Branch master set up to track remote branch master from origin.
11. 此时再次查看一下仓库状态
- $ git status
- On branch master
- Your branch is up-to-date with 'origin/master'.
- nothing to commit, working directory clean
只要你对工作区没有任何的修改,工作区就是干净的
来源: http://www.bubuko.com/infodetail-1985022.html