本地项目上传至guthub

2019-02-19  本文已影响0人  Gary134

1.建立本地仓库

进入目标文件夹下,执行

git init

初始化成功后你会发现项目里多了一个隐藏文件夹.git

2.所有文件添加至仓库

git add .

3.提交文件

git commit -m "提交文件"
# 引号内为提交注释

4.关联GitHub仓库

# 到github text仓库复制仓库地址
git remote add origin https://github.com/Garyzjl/i_home.git

5.通过如下命令进行代码合并

git pull --rebase origin master

执行上面代码后可以看到本地代码库中多了README.md文件

6.上传本地代码

git push -u origin master

7.完成

可以看到我们的本地项目已经上传到了github上了


1.GitHub项目文件下载至本地

git clone 下载文件链接(https://github.com/Garyzjl/i_home.git)

2.下载GitHub上的某个文件

打开文件夹,复制浏览器中的地址:如

https://github.com/Garyzjl/i_home/tree/master/static/images
将”/tree/master/”替换成”/trunk/”,则新生成的新链接为:https://github.com/Garyzjl/i_home/trunk/static/images

注意:这里根据分支的不同,通用的办法是将”/branches/branchname/”替换成”/trunk/”。例如:”/tree/master/” to “/trunk/” ; “/tree/develop/” to “trunck”

[(1.png] 2.png
svn checkout SVNURL(SVNURL就是step1中生成的url)

执行代码:

svn co https://github.com/Garyzjl/i_home/trunk/static/images

3.切换分支

git branch -a   # 查看所有分支

git checkout -b <分支名称>  # 切换分支

git checkout master      # 切换回主分支

git reset --hard  <版本号>   # 回滚到某个版本
上一篇 下一篇

猜你喜欢

热点阅读