git 在android studio中删除旧的并添加新的git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31990372/
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
Remove old and add new git in android studio
提问by user345280
I have tried to configure android studio with git and messed up.
我试图用 git 配置 android studio 并搞砸了。
How to completely remove old git that I could create new one?
如何完全删除我可以创建新的旧 git?
回答by neshkeev
In order to drop the current git repository and create a new one you need to:
为了删除当前的 git 存储库并创建一个新的存储库,您需要:
Go to the project's directory:
cd PROJECT_DIRECTORY
Remove all the git specific files:
rm -rf $(find . -name ".git*")
Initialize a new git repository:
git init
进入项目目录:
cd PROJECT_DIRECTORY
删除所有 git 特定文件:
rm -rf $(find . -name ".git*")
初始化一个新的 git 仓库:
git init
This doesn't remove your project's files, only git configs
这不会删除您的项目文件,只会删除 git configs
回答by Nihas Nizar
Just a simple way
只是一个简单的方法
Open the terminal in android studio.
在 android studio 中打开终端。
git remote set-url origin <NEW GIT URL>
now the project url is changed from old link to new one. Then you can use >
现在项目 url 从旧链接更改为新链接。然后你可以使用 >
git init
and upload your files. Happy coding :)
并上传您的文件。快乐编码:)
回答by DeepBlue
I find the top answer little bit too complicated, although fully functional. So here is maybe little bit easier to understand practice:
我发现最高答案有点太复杂了,尽管功能齐全。所以这里可能更容易理解实践:
Assuming you already have project, and you want to change target (Bitbucket in my case) directory.
假设您已经有项目,并且您想更改目标(在我的情况下为 Bitbucket)目录。
- Go to project directory:
cd Your/project/location
- Find your current remote:
git remote
(its name will be probablyorigin
) - Delete it:
git remote remove yourOldRemoteName
- Make sure you deleted the remote:
git remote
(should display nothing) - Create new remote:
git remote add yourNewRemoteName repositoryUrl
- 进入项目目录:
cd Your/project/location
- 找到您当前的遥控器:(
git remote
它的名字可能是origin
) - 删除它:
git remote remove yourOldRemoteName
- 确保您删除了遥控器:(
git remote
不应显示任何内容) - 创建新的遥控器:
git remote add yourNewRemoteName repositoryUrl
(If you are using Bitbucket, your url will be something like https://[email protected]/your-company/yourRepository.git
and you will find it by clicking Clone
button in source folder of your repository or when creating the repository.)
(如果您使用的是 Bitbucket,您的 url 将类似于https://[email protected]/your-company/yourRepository.git
您可以通过单击Clone
存储库源文件夹中的按钮或在创建存储库时找到它。)
Hope this will be useful!
希望这将是有用的!
回答by Ben
Delete the .git folder & .gitignore and start again.
删除 .git 文件夹和 .gitignore 并重新开始。
Google for how to display hidden folders on windows to see the .git folder.
Google 了解如何在 Windows 上显示隐藏文件夹以查看 .git 文件夹。
回答by Abhishek
Remove the git folder in Project directory
Run this command
git init
in TerminalVcs=> Git=>remote and add new
Paste the new git URL
After, verify your GitHub credentials
删除项目目录下的git文件夹
git init
在终端中运行此命令Vcs=> Git=>remote 并添加新的
粘贴新的 git URL
之后,验证您的 GitHub 凭据
Now new git attached to your project
现在新的 git 附加到您的项目