任何人都可以从 GitHub "git tutorial"解释这些命令行吗?



每次在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

但是我不知道他们到底在做什么…有人能帮帮这个可怜的菜鸟吗?

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

最新更新