现在的位置: 首页 > 综合 > 正文

github和把web.py部署到heroku的常用命令和注意

2017年12月20日 ⁄ 综合 ⁄ 共 1443字 ⁄ 字号 评论关闭

前几天使用git管理代码,并将web.py部署到heroku.总结一下一些经验.不太适合新手看.

首先总体部署可以参考我转载的<在Heroku上部署web.py应用>一文中的内容.

我总结一下一些常用命令

ssh-keygen -t rsa -C "xxxx@163.com"  #一路回车即可,生成ssh-key密钥对放在默认的目录就好

(heroku keys:add) #将公钥上传heroku(heroku login过的账户)

ssh -T git@github.com #测试一下是否通过验证

一个完整的上传过程:(以上传到heroku为例)

heroku create --stack cedar project_name #这条命令会在heroku上创建一个project_name项目,上传到github的可以忽略此步骤

git remote add heroku git@heroku.com:project_name.git
#连接到远程的项目目录add后可以自定义命名.连接到github可用git remote add origin git@github.com:github用户名/project_name.git

(git init)

(git add .)

(git commit -m "first commit") #这三条命令在上传到github时可用(git commit -am "first commit"可以增量提交)

git push heroku master #上传到master(默认分支)

git remote -v #查看远程连接了哪些项目

git remote rm xxx #xxx为上面git remote add 命令后的名字,移除改项目目录

git branch branch_name #新建分支

git checkout branch_name #切换分支

git branch -D branch_name #删除分支

git push origin branch_name #上传到分支

git branch --all #查看所有分区


git tag v1.0 #定义版本v1.0

git push origin v1.0 #上传tag版本


克隆:

git clone https://项目地址

克隆下来的项目就是完整的了.

可以进入克隆的项目使用git checkout branch_name 即可切换本地的分支

git checkout local_dirname origin:remote_branch_name 
# 创建本地分支dev,并且和远程origin/dev分支关联,本地dev分支的初始代码和远程的dev分支代码一样

只想克隆一个分支的代码:

git clone -b branch_name https://项目地址

可能出错问题:

1. fatal: Not a valid object name: 'master'. 原因是没有commit就push了

可参考http://tanglei528.blog.163.com/blog/static/43353399201302354346563/

2.To
prevent you from losing history, non-fast-forward updates were rejected

Merge the remote changes before pushing again.  See the 'non-fast forward'
section of 'git push --help' for details. 

可参考:http://www.linuxidc.com/Linux/2012-04/58985.htm

抱歉!评论已关闭.