上传本地代码到github&&从github下载源码

 

最近在玩github,下面简单介绍下githup的使用

将本地代码同步到github.

使用Git GUI同步 

1,先下载git,然后安装。右键如图所示。

2,在github里新建一个 repository。

复制地址待用:https://github.com/x/spring-mvc-study

3,启动git GUI,新建一个repository,选择目录为你要上传到github的项目根目录。

如下;

4,建立远程repository映射。如下:

5,commit代码,之前可以rescan下

6.push代码到github。选择之前建立的repository。

 

最后出现成功提示,刷新github页面就能看到提交的代码了。

使用Git Bash同步

 也可以使用以下命令提交:

1,当前项目目录:git clone https://github.com/************.git  #(https://github.com/************.git替换成你之前复制的地址)
这个步骤以后你的本地项目文件夹下面就会多出个文件夹,该文件夹名即为你github上面的项目名,吧这个新增目录下的文件copy到本地项目目录下,并删除这个新增目录。

2,
当前项目目录:git add .

3,当前项目目录:git commit
-m “初始化代码”

4,当前项目目录:git push origin master

 

下面介绍下从github下载源码

 首先在项目目录右键,选择git bash here(选择git gui here 也可以),打开提示行并输入用户名和邮箱:

git config --global user.name "sudo"

git config --global user.email "sudo@qq.com"

 

然后输入以下命令来初始化:

  git init

  git remote add origin https://github.com/x/online-message-dev.git

然后就克隆项目到本地:

git clone https://github.com/x/online-message-dev.git

更新项目:

git pull origin master 

 附:

git 代理设置:

C:\Users\用户  下的.gitconfig文件末尾添加如下内容:

[http]

  proxy = http://www.proxy.com:8080/

 

参考:博客园 git bash

posted @ 2016-06-07 13:58  权杖攻城狮  阅读(667)  评论(0编辑  收藏  举报