从 git 克隆 repo 后要做什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14344832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What to do after cloning repo from git
提问by Trialcoder
I am just a git starter, basically I clone a git repository and now I wanted to commit the changes that I made in a file. when I run the command git commit
it says not a git repository
,
我只是一个git starter,基本上我克隆了一个 git 存储库,现在我想提交我在文件中所做的更改。当我运行命令时,git commit
它说not a git repository
,
So being a starter in git i just wanted to ask that do i need to run this command first - git init
and then git commit
? Or in between these some more steps to follow to commit the file?
因此,作为 git 的初学者,我只想问我是否需要先运行此命令 -git init
然后再运行git commit
?或者在这些更多步骤之间提交文件?
I need to commit files on Bitbucket.
我需要在 Bitbucket 上提交文件。
Screenshot-
截屏-
回答by David Culp
As jeremyharrissaid, the git documentation siteand especially the online bookthere will get you up to speed on the basics.
正如jeremyharris所说,git 文档站点,尤其是那里的在线书籍将帮助您快速了解基础知识。
A few quick notes that might get you past your initial issue.
一些快速说明可能会让您解决最初的问题。
git clone
command is used to pull a copy (a clone) from an existing git repository. By default it creates a folder in the folder you execute it from that has a .git
folder in it. The folder the cloning creates is your working copy and the .git
folder is your local copy of the repository.
git clone
命令用于从现有的 git 存储库中提取副本(克隆)。默认情况下,它会在您执行它的文件夹中创建一个文件夹,其中包含一个.git
文件夹。克隆创建的文件夹是您的工作副本,该.git
文件夹是您的存储库的本地副本。
git clone
is different than most other git commands. All (or most?) other git commands require the command to be executed within the working copy folder created by the clone. (Bare repositories are a bit different since they don't have working copies, but that shouldn't apply here.) So, after doing:
git clone
与大多数其他 git 命令不同。所有(或大多数?)其他 git 命令都需要在克隆创建的工作副本文件夹中执行该命令。(裸仓库有点不同,因为它们没有工作副本,但这不应该在这里适用。)所以,在做之后:
$ git clone <remote repo> <repo name>
do:
做:
$ cd <repo name>
to get into the working copy before executing any other commands. Executing commands outside of the working folder will get you the not a git repository
message.
在执行任何其他命令之前进入工作副本。在工作文件夹之外执行命令将为您提供not a git repository
消息。
After making a change to a file, git add <filename>
adds it to the index (marked to indicate ready to commit) and git commit -m '<commit message>'
will then commit the changes.
对文件进行更改后,git add <filename>
将其添加到索引(标记为表示准备提交),git commit -m '<commit message>'
然后将提交更改。
回答by Billy Chan
You need to add the change at first, use git add .
您首先需要添加更改,使用 git add .
You can also check the status before adding, by using git status
您还可以在添加之前检查状态,方法是使用 git status
EDIT
编辑
Just saw the comments about error. Yes that's correct. I neglect that.
刚刚看到关于错误的评论。对,那是正确的。我忽略了这一点。
Your problem is you need to cd
the git folder at first.
你的问题是你首先需要cd
git 文件夹。
After that, you still need to add
as my answer above.
在那之后,你仍然需要add
按照我上面的回答。