繁体   English   中英

git 如何在创建存储库后首次提交

[英]git how to do first commit after creating a repository

我使用 git。我创建了一个目录 reflections4 并在其中复制了一个文件。 在此之后,我执行了 git init。

git log displays 

carlotavina (master #) reflections4 $ git log
fatal: your current branch 'master' does not have any commits yet

git status

carlotavina (master #) reflections4 $ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    lesson_1_reflections.txt 

nothing added to commit but untracked files present (use "git add" to track)

创建存储库后如何在 git 状态中显示初始提交

您还没有向存储库提交任何内容,只进行了初始化。 从下面链接的文档中,init创建一个空的存储库,并且没有填充。 某些服务(github / lab等)将使用自述文件或类似文件初始化存储库,必须提交跟踪文件。 手动运行init不会这样做。

你必须向空的repo添加(提交)一些东西才能看到它。 因此,如果您git add lesson_1_reflections.txtgit commit -m "first commit" ,那么您将拥有一个能够查看的提交。

如果您尝试与远程存储库(托管在另一台服务器,github,gitlab,bitbucket等上)进行同步,则必须采取其他步骤才能使两个存储库(本地和远程)相互通信。

https://git-scm.com/docs/git-init

第1步:

git add lesson_1_reflections.txt

第2步:

git commit -m "<enter the desired commit message>"

第3步(设置遥控器后推入):

git push

如果提示输入用户名和密码

https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html在此网页上了解您可以找到您想要的所有信息。

在您的情况下,您必须将这些文件添加到您的存储库中

git add . // . means everything or "all"

git status // now you can see all the changes
git commit -m "Message that you want to send regarding this commit"
git push origin "whatever the branch name"(optional)

当你有空回购时。 您可以按照以下步骤进行初始提交。

  1. 克隆空回购。 git clone <your git repo url>
  2. 现在 go 使用cd命令到你的 repo 并使用命令git checkout -b development创建一个本地分支说developement
  3. 我们现在可以在回购中添加一些文件echo "A new repo" > Readme
  4. 暂存所有未暂存文件以提交git add.
  5. 显示暂存文件git status
  6. 将文件提交到本地 git repo git commit -m "Adding readme file"
  7. 使用git push -u origin development:development将提交推送到您的远程仓库

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM