github 安装和用法

github 安装和用法
github安装下载地址:http://git-scm.com/download/

启动安装好的git bash命令行操作
配置全局参数
git config --global user.name “hsg77”
git config --global user.email "hsg77@163.com"

转到开源工程目录
cd e/soft_opensource/closeprocess

//把这个目录变成Git可以管理的仓库
git init

git init //把这个目录变成Git可以管理的仓库
git add README.md //文件添加到仓库
git add . //不但可以跟单一文件,还可以跟通配符,更可以跟目录。一个点就把当前目录下所有未追踪的文件全部add了
git commit -m “first commit” //把文件提交到仓库
git remote add origin git@github.com:hsg77/closeprocess.git //关联远程仓库
git push -u origin master //把本地库的所有内容推送到远程库上

下载github上的一个项目源码的方法:
git clone 你复制的项目地址
如下git bash命令行中操作:
cd e/soft_opensource/geowave-master
//ssh方式下载
git clone git@github.com:hsg77/geowave-hsg77.git

//https方式下载
git clone https://github.com/hsg77/geowave-hsg77.git

cd e/soft_opensource/geowave-hsg77
//下载最新源码到本地库 命令行
//fetch=接来,取来,拿来
git fetch

remote: Enumerating objects: 1324255, done.
remote: Counting objects: 100% (1322933/1322933), done.
remote: Compressing objects: 100% (116671/116671), done.
Receiving objects:   0% (303/1321758), 60.00 KiB | 3.00 KiB/s

//pull = 拉过来
git pull

remote: Enumerating objects: 1324255, done.
remote: Counting objects: 100% (1322933/1322933), done.
remote: Compressing objects: 100% (116671/116671), done.
Receiving objects:   0% (988/1321758), 188.00 KiB | 17.00 KiB/s

新建开源项目并上传到远程仓库中的方法:
前提:在github上手动创建仓库如:javaConsole
然后拷贝地址:https://github.com/hsg77/javaConsole.git

在本地按照如下的命令进行

#新建工程
mkdir javaConsole 
#或者IJ ide创建新工程目录,然后进入到新工程的根目录,然后cmd中初始化本地仓库git init

#如果是已存在的工程项目,则直接cd到项目根目录下,不需要新建。
cd javaConsole

#初始化本地仓库
git init 

#添加要push到远程仓库的所有文件或文件夹
git add *

#添加要push到远程仓库的指定的文件xxx或文件夹xxx
git add xxx     

#提交修改代码到本地master仓库
git commit -m ‘first commit’

#建立远程仓库
git remote add origin https://github.com/hsg77/javaConsole.git 

#可以通过如下命令进行本地代码与远程仓库代码的合并【注:pull=fetch+merge]
#下载并合并
git pull --rebase origin master

#将本地仓库代码push到远程仓库
git push -u origin master 

需要注意的是:一定要在github上手动创建仓库javaConsole

报如下错误的解决办法:

 ! [rejected]            master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/hsg77/geowave-hsg77.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决办法:
1,当你处于master branch, 默认的remote就是origin。
2,当你在master branch上使用git pull时,没有指定remote和branch,那么git就会采用默认的remote(也就是origin)来merge在master branch上所有的改变
如果不想或者不会编辑config文件的话,可以在bush上输入如下命令行:

$ git config branch.master.remote origin  
$ git config branch.master.merge refs/heads/master  
git pull
git push

之后再重新git pull下。最后git push你的代码吧。it works now~

参考地址:
git安装
https://www.cnblogs.com/specter45/p/github.html

Git客户端(TortoiseGit)基本使用详解
https://www.cnblogs.com/xuwenjin/p/8573603.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值