【从小白到猿猴】上传本地代码到GitHub仓库

来源:互联网 发布:mahout聚类算法实现 编辑:程序博客网 时间:2024/05/21 08:54
前面我们已经讲了,现在我们来讲如何上传本地代码!


课程概述
  1. 创建仓库
  2. 链接仓库
  3. 公开代码

  • 创建仓库
         第一步:登陆 https://github.com 
         第二步: 点击图中红色框中的 “+” 或者 “+New repository" 
        
           第三步:填写相关信息
                                           


        Repository Name:  仓库名称
        Description :仓库说明(根据需要填写,可以不填)
        Public、Private : 如果选择Public,仓库内的所有内容都可以被别人查看;如果选择Private,用户可以设置权限(此项服务是收费的)
        Initialize this repository with a README ,如果选择,随后GitHub 就会自动初始化并设置README文件,让用户可以立刻克隆这个仓库,如果想选向     GitHub添加已有的Git库,建议不需要勾选,手动Push.
        Add.gitignore:自动生成 .gitignore 文件(根据需要,自行选择)
        Add.license:添加许可协议(根据需要自行选择)
            
  • 链接仓库
          创建的仓库的URL
  • 公开代码
    $ git clone "仓库地址"
Lunatic@DESKTOP-NFFISQN MINGW64 ~ (master)
$ git clone git@github.com:DangJin/Hello-World.git
fatal: destination path 'Hello-World' already exists and is not an empty directo ry.
 
Lunatic@DESKTOP-NFFISQN MINGW64 ~ (master)
$ cd Hello-World
 
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
### 我们需要找到我们在本地缓存文件地址,然后将代码放置Clone生成的文件夹的根目录下 然后 push
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git status
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)
 
Hello_World.php



$ git add ”文件名“
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git add Hello_World.php
 
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git commit -m "Add hello world script by php"
[master 013774f] Add hello world script by php
1 file changed, 3 insertions(+)
create mode 100644 Hello_World.php
 
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git log
commit 013774f7a20a4942131273ee43ca08b826c3b02c
Author: DangJin <990171616@qq.com>
Date: Wed Jan 13 23:44:33 2016 +0800
 
Add hello world script by php
 
commit 9e839031df35ff03f141998fb615d57b31db6e91
Author: DangJin <990171616@qq.com>
Date: Tue Jan 12 13:01:37 2016 +0800
 
Initial commit
 
$ git push
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 324 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:DangJin/Hello-World.git
9e83903..013774f master -> master

好了 快来自己实践一下啦啦啦~~


前面我们已经讲了,现在我们来讲如何上传本地代码!


课程概述
  1. 创建仓库
  2. 链接仓库
  3. 公开代码

  • 创建仓库
         第一步:登陆 https://github.com 
         第二步: 点击图中红色框中的 “+” 或者 “+New repository" 
        
           第三步:填写相关信息
                                           


        Repository Name:  仓库名称
        Description :仓库说明(根据需要填写,可以不填)
        Public、Private : 如果选择Public,仓库内的所有内容都可以被别人查看;如果选择Private,用户可以设置权限(此项服务是收费的)
        Initialize this repository with a README ,如果选择,随后GitHub 就会自动初始化并设置README文件,让用户可以立刻克隆这个仓库,如果想选向     GitHub添加已有的Git库,建议不需要勾选,手动Push.
        Add.gitignore:自动生成 .gitignore 文件(根据需要,自行选择)
        Add.license:添加许可协议(根据需要自行选择)
            
  • 链接仓库
          创建的仓库的URL
  • 公开代码
    $ git clone "仓库地址"
Lunatic@DESKTOP-NFFISQN MINGW64 ~ (master)
$ git clone git@github.com:DangJin/Hello-World.git
fatal: destination path 'Hello-World' already exists and is not an empty directo ry.
 
Lunatic@DESKTOP-NFFISQN MINGW64 ~ (master)
$ cd Hello-World
 
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
### 我们需要找到我们在本地缓存文件地址,然后将代码放置Clone生成的文件夹的根目录下 然后 push
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git status
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)
 
Hello_World.php



$ git add ”文件名“
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git add Hello_World.php
 
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git commit -m "Add hello world script by php"
[master 013774f] Add hello world script by php
1 file changed, 3 insertions(+)
create mode 100644 Hello_World.php
 
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git log
commit 013774f7a20a4942131273ee43ca08b826c3b02c
Author: DangJin <990171616@qq.com>
Date: Wed Jan 13 23:44:33 2016 +0800
 
Add hello world script by php
 
commit 9e839031df35ff03f141998fb615d57b31db6e91
Author: DangJin <990171616@qq.com>
Date: Tue Jan 12 13:01:37 2016 +0800
 
Initial commit
 
$ git push
Lunatic@DESKTOP-NFFISQN MINGW64 ~/Hello-World (master)
$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 324 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:DangJin/Hello-World.git
9e83903..013774f master -> master

好了 快来自己实践一下啦啦啦~~



0 0