git 为来自 Ubuntu 的现有文件创建一个新的 BitBucket 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20045228/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:22:15  来源:igfitidea点击:

Create a new BitBucket repository for existing files from Ubuntu

gitubuntubitbucket

提问by matdev

I have files that I want to add to a new repository on BitBucket. How can I do this using a command line from Ubuntu ?

我有一些文件要添加到 BitBucket 上的新存储库中。如何使用来自 Ubuntu 的命令行执行此操作?

An alternative would be to create the repository first from the BitBucket website but I don't know how to clone a repository into a non-empty directory.

另一种方法是首先从 BitBucket 网站创建存储库,但我不知道如何将存储库克隆到非空目录中。

采纳答案by Number8

More detail on Bruce's comment:

关于布鲁斯评论的更多细节:

When you create a repo at BitBucket, you are offered two links:

当你在 BitBucket 创建一个 repo 时,你会看到两个链接:

  • "I'm starting from scratch"
  • "I have an existing project to push up"
  • “我从头开始”
  • “我有一个现有的项目要推”

Click on the 2nd, and you will be given the commands to run in your local repo. These would look like:

单击第二个,您将获得在本地存储库中运行的命令。这些看起来像:

> cd /path/to/my/repo
> git remote add origin https://[email protected]/me/test.git
> git push -u origin --all # pushes up the repo and its refs for the first time
> git push -u origin --tags # pushes up any tags

回答by Samitha Chathuranga

You do not need to do a clone anyway. And also the accepted answer is not correct. You need to do a git add .and then git commitbefore pushing.

无论如何您都不需要进行克隆。而且接受的答案也不正确。在推动之前,你需要做一个git add .然后git commit

This is the complete set of steps to follow, to do what you want: Create a git BitBucket/ Github repository from already locally existing project - samranga.blogspot.com

这是要遵循的完整步骤集,以执行您想要的操作: 从本地现有项目创建一个 git BitBucket/Github 存储库 - samranga.blogspot.com