简体   繁体   English

在Android Studio 2.2.2中从BitBucket提取提交

[英]Pulling A Commit from BitBucket in Android Studio 2.2.2

I recently upgraded to Android Studio 2.2.2. 我最近升级到Android Studio 2.2.2。 I have several commits in BitBucket, but I want to pull a specific commit into a new Android Studio project. 我在BitBucket中有多个提交,但是我想将特定提交提交到新的Android Studio项目中。

I understand there is a BitBucket plugin, however I do not see any way to install the plugin in Android Studio 2.2.2. 我了解有一个BitBucket插件,但是在Android Studio 2.2.2中看不到任何安装插件的方法。 I also know that there are 2 methods of cloning in Git: SSH and HTTPS. 我也知道在Git中有2种克隆方法:SSH和HTTPS。 Not sure which one to use or what the best method of pulling a specific commit would be. 不知道要使用哪种方式,或者不确定哪种最佳方式来执行特定的提交。 Any help would be appreciated! 任何帮助,将不胜感激!

I can't help you with Android Studio and Bitbucket plugin, but the following information may be useful for you. 我无法为您提供Android Studio和Bitbucket插件,但是以下信息可能对您有用。

SSH or HTTPS. SSH或HTTPS。 I recommend to use SSH method, in this case you should never enter your password for connect with Bitbucket server. 我建议使用SSH方法,在这种情况下,您永远不要输入用于连接Bitbucket服务器的密码。 See https://stackoverflow.com/a/40632487/637589 参见https://stackoverflow.com/a/40632487/637589

After you've cloned the repository you have master as a current branch. 克隆存储库后,您便拥有master作为当前分支。 If you want just review all files in specific commit use this command line: 如果只想查看特定提交中的所有文件,请使用以下命令行:

git checkout <your-commit-SHA1>

If want to work (change, commit and so on) basing on this commit - you need to create a new branch: 如果要基于此提交工作(更改,提交等),则需要创建一个新分支:

git checkout <your-commit-SHA1> -b <name-of-new-branch>

I believe you can do the same things using any git plugin to Android Studio 我相信您可以使用Android Studio的任何git插件执行相同的操作

There is nothing special about BitBucket. BitBucket没有什么特别的。 It's a regular git repository. 这是一个常规的git仓库。 I don't think you need a plugin. 我认为您不需要插件。

First, setup your project with git (there are many tutorials on the internet). 首先,使用git设置项目(互联网上有很多教程)。 The way I do it: 我的方式:

  • Create new repository on BitBucket 在BitBucket上创建新的存储库
  • open command line and go to the path where you want your new project 打开命令行并转到您要创建新项目的路径
  • type git clone {git url} (you can find it in BitBucket under Overview: git@bitbucket.org:../...git) 输入git clone {git url}(您可以在BitBucket中的Overview下找到它:git@bitbucket.org:.. / ... git)
  • open this newly created folder in Android Studio 在Android Studio中打开此新创建的文件夹

If you want to checkout a specific commit you can do it in the command line: 如果要签出特定的提交,可以在命令行中进行:

git checkout <commit-SHA1>

Or you can do it in Android Studio. 或者,您可以在Android Studio中进行操作。 Click on the Version Control and you'll see all the commits: 单击版本控制,您将看到所有提交:

在此处输入图片说明

Right-click on your specific commit and select Checkout revision. 右键单击您的特定提交,然后选择Checkout版本。

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

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