git指令
程序员文章站
2022-07-02 23:21:33
...
工作区
一个你存放代码的目录相当于一个工作区
版本库
在你的工作区中创建一个新仓库
git init
//将文件添加到暂存区(stage)
git add <file>
//将所有文件添加到暂存区(stage)
git add .
//提交到HEAD
git commit -m "代码提交信息"
//添加远程仓库地址
git remote add origin <url>
//提交到远程仓库,master是你要推送的分支
git push origin master
若出现此类错误
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Tommy-Enrique/dsaa-code.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.
则可输入
//强制更新推送
git push --force <url>
上一篇: 霸王餐