Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Best practice to commit changes from Visual Studio 2017?

ic2 July 25, 2018

I have installed Bitbucket to be used for Visual Studio (2017) source control.

I am confused especially by one thing. When I create a repository in the Bitbucket cloud (website), as administrator, I can clone it to my local Pc (e.g. using Sourcetree for it) which asks a directory, e.g. e:\BitBucket\something. But after that I can't commit from Visual Studio; the commit option is not there. For that I first have to choose in VS File/Add to source control. This creates a directory .git en 2 files .gitattributes en .gitignore within my project directory. If I would delete those, source control is gone.

But I want to commit changes to the local (cloned) copy of my Bitbucket repository, which resides on another disk (like the mentioned e:\BitBucket\something). Now I have two local repo's and I don't want the one created in my project directory.

Is there any way to accomplish Visual Studio committing changes to a local repository of choice, and this one writing to the Bitbucket cloud repository it is cloned from?

 

Dick

2 answers

2 votes
Deleted user August 1, 2018

Hello @ic2,

To commit from the Bitbucket for Visual Studio plugin, you need to first configure it with the Bitbucket repo you want to commit to. 

 

1. Go to Team Explorer in Visual Studio

2. (If you have loaded the Bitbucket plugin for Visual Studio the Bitbucket option will appear on top) Click on Login under the Bitbucket logo

3. Login to your Bitbucket account. 

4. Now instead of the Login button you will find a list of all your Bitbucket Cloud repos.

5. Select the repo and check your connection

6. Open the project solution you want to commit to Bitbucket

7. In the Team Explorer, click on "Connect" in the top and change to "Changes

8. Here you will find all the changes in the current solution and the repo and branch it is ready to push to

9. Stage the changes you want to commit, add the commit message and click Commit Staged.

10. Go to the Sync tab within Team Explorer and you will see your commit in the Push tab. 

11. Push the commit and you are done! 

 

Phew... that was long! But you'll get used to after one or two commits!

Happy committing! :) 

 

Don 

ic2 August 7, 2018

Hello Don,

 

Thanks for the description. I followed it step by step but without choosing File/Add to source control in Visual Studio, nothing can be committed. As soon as I do chose File/Add to source control, the .git data are stored with the project, not in a separate directory.

So I guess this is not possible.

 

Dick

Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 22, 2018

 

Hi Dick! Visual Studio shouldn't be asking you to "Add files to source control" if the files are already been source controlled (they've been initialized in Git, which is a Source Control system) 

Sounds like the directory you're trying to use is not a Git repository yet, can you confirm you're using the same one you just cloned from Bitbucket (and not any other copy that you had in your machine)? That would give us a reason why you couldn't commit, by adding the .git Visual Studio is turning a regular directory into a repository which will be now ready to commit.

I'm not sure I fully understand this part:

But I want to commit changes to the local (cloned) copy of my Bitbucket repository, which resides on another disk (like the mentioned e:\BitBucket\something). Now I have two local repo's and I don't want the one created in my project directory.

Is this the same repo you were trying to use with Visual Studio? If it is, then you'll probably need to contact Visual Studio support team to know why it's not allowing you to commit to an existing repo.

Hope that helps!

Ana

0 votes
ic2 August 28, 2018

Hello Ana,

 

Thanks for your reply. I think the only way for Visual Studio to create a repo is to do that within the project directory. I am not really a fan of Visual Studio as it usually works differently to what I find handy or logical. Visual Studio support usually doesn't know much more either ;).

 

I used to work with SVN & Tortoise which could create the repo anywhere. But this system did not write to cloud repo's so it was more important to separate the solution's work disk from the repo disk. And SVN & Tortoise weren't exactly ideal so I think/hope Bitbucket with local repo's will be much better in the end.

 

Dick

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events