git - 任何人都可以从 GitHub“git 教程”中解释这些命令行吗?
问题描述
每次您在 GitHub 上创建新存储库时,它都会向您显示这些我一直觉得有用的命令行...
echo "# Project" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin https://github.com/Username/Project.git
git push -u origin master
但我不知道他们到底在做什么......谁能帮助这个可怜的 Git 新手?
解决方案
echo "# Project" >> README.md
这会在您的当前目录中创建一个 README
git init
这将创建一个新的 .git 目录来存储提交和其他对象。
git add README.md
在将文件添加到存储库之前,必须先暂存它。
git commit -m "initial commit"
这会将我们的分阶段更改提交到存储库中。
git branch -M master
使用 -m 或 -M 选项,oldbranch 将被重命名为 newbranch。如果 oldbranch 有相应的 reflog,它会被重命名以匹配 newbranch,并创建一个 reflog 条目来记住分支重命名。如果 newbranch 存在,则必须使用 -M 强制重命名发生
git remote add origin https://github.com/Username/Project.git
这会将远程 url 添加到现有的 git 存储库
git push -u origin master
Push - 将本地更改(或快照)移动/上传到远程 GitLab 存储库
有用的链接: https ://learngitbranching.js.org/ https://doane-ccla.gitbook.io/docs/git-version-control/git-basics
推荐阅读
- php - 如何通知 Zend 3 控制器有关 MVC 错误事件?
- docker - CentOS 7.5 上是否提供 docker 存储驱动程序 overlay2 生产?
- c# - 字典列表只保留最后一行
- python - 如何读取保存的图像并将其定位在没有任何扭曲的坐标中?
- javascript - 反应片段有意外的令牌错误?
- spring - 使用 Hibernate 和 Oracle 在 Spring Boot 应用程序中由对等方重置连接
- reactjs - 开玩笑如何检查在间谍函数中调用的间谍函数?
- python - Python-Scapy 区分接入点到站
- python - 使用 Python 从 Outlook 下载附件
- jenkins - 用于 Maven 类型 Jenkins 作业的 dsl 脚本