git使用(二)部署本地项目到github

    技术2022-07-11  106

    部署本地项目到github

    初始化

    打开Git Bash。 cd到项目文件夹。(直接把文件夹拖入到bash内即可) 执行初始化代码

    git init

    项目文件夹会产生一个.git的文件夹

    跟github仓库关联

    格式:

    git remote add origin url地址(https或ssh)

    例如:

    git remote add origin git@github.com:rmxob/c--jifenduihuan.git

    取消关联

    git remote rm origin

    把项目推送到github

    (1)如果在仓库中创建了readme文件,就先pull一下

    git pull origin master --allow-unrelated-histories

    (2)把目标文件/文件夹添加到暂存区 我这是完整的项目,所以用.表示全部

    git add .

    (3)推送至本地数据仓库

    git commit -m "frist"

    (4)推送到github上

    git push origin master

    这样项目就推送到了github上了。

    .gitignore

    .gitignore 文件:可以在推送时忽略选定的文件。 (1)创建.gitignore文件 可以手动创建,也可以用命令创建

    touch .gitignore

    (2)把不需要推送的文件/文件夹添加到.gitignore文件中 edit .gitignore文件,把文件名添加到gitignore文件就行了。

    从0开发

    一般是先有的远程库,从远程库克隆

    git clone 远程库的地址
    Processed: 0.011, SQL: 9