Host an ASP.Net Core project in Bitbucket (Using Visual Studio for Mac)
When you are stared to do your own project the main concern and the importance will be the security of your source code. How do you make sure it is safe? What happen if you lose your hard drive or your laptop which have all your project source code? All of your effort will lose, isn't it?
But nowadays you can safeguard your code using a source control service.
Bitbucket is a great place to start. It has a free plan for small teams, so you can use this.
In this post I'll explain how to host your .Net Core project using Bitbucket from mac.
Let's get started.
Prerequisites
Before we get stared you have to install following in your mac.
1. Git - Download it from https://git-scm.com/downloads and install it.
2. Visual Studio for Mac - Download it from https://www.visualstudio.com/vs/mac/ and install it.
Ok. I assume that you have all the prerequisite software installed in your mac.
Now follow the bellow steps.
1. Create an account in Bitbucket (https://bitbucket.org/) if you have not created one before.
2. Create a repository in Bitbucket with your project name. I'll create one as MyAPI because I'm going to host an ASP.Net Core Web API project.
Give a name to your repository and Select No for Include a Readme.
3. Inorder to manage things in git we need a tool.
Since we are using Bitbucket which provides by Atlasian, I'm going to use their git GUI tool called Sourcetree. Go to https://www.sourcetreeapp.com and download it for free.
4. Open Sourcetree app in your mac and go to New --> Clone from URL
4.1. Go to your Bitbucket repository (MyAPI) and copy the repository clone url.
NOTE: Don't copy the 'git clone ' part of the text.
4.2. Paste the copied text inside the 'Clone a Repository' section in Sourcetree.
4.3. Click on Clone.
5. Create a folder called MyAPI_Temp in your mac.
6. Let's create our actually project now.
Open Visual Studio for Mac and create a .Net Core project. In this scenario I have created an ASP.Net Web API project called MyAPI (which has the similar name of our Bitbucket repository).
6.1. Don't select 'Use git for version control' check box.
6.2. Don't give the destination path of the repository that we have just cloned !!!
6.3. Select the path of above mentioned folder (MyAPI_Temp)
6.4. Build your project ignorer to verify it has no build errors.
6.5. Close the solution from Visual Studio.
7. Go to the project folder (MyAPI_Temp) and copy all the content of it.
8. Go to the local repository folder (MyAPI) which was cloned from Bitbucket.
8.1. Paste the content of MyAPI_Temp folder to here.
9. Open Sourcetree and you will see there is an uncommited change.
9.1. Make sure the changes are correct and select all the files that need to be committed.
9.2. Give a commit message and click Commit
10. Push the changes
10.1. Click on Push ison in Souretree
10.2. Select the branch that you have to push and click Ok.
10.3. After the push you will get an success message.
Done.
We have successfully push our project to git repository in Bitbucket.
You can visit Bitbucket MyAPI repository to verify our project has been copied to it.
Work in the MyAPI project
Now we have initialize our project with the git.
But in Visual Studio our project have mapped with non git manage folder (MyAPI_Temp)
So, just delete that folder.
Now when you open your MyAPI project in Visual Studio it will complain there is no MyAPI project so it has to removed from the project list.
Click on Yes.
Now. Open your MyAPI app from Visual Studio by selecting the path to MyAPI folder.
Do a change to a file.
And go to your Souretree to identify your change has been captured by git.
Thats all...
Happy Coding....
But nowadays you can safeguard your code using a source control service.
Bitbucket is a great place to start. It has a free plan for small teams, so you can use this.
In this post I'll explain how to host your .Net Core project using Bitbucket from mac.
Let's get started.
Prerequisites
Before we get stared you have to install following in your mac.
1. Git - Download it from https://git-scm.com/downloads and install it.
2. Visual Studio for Mac - Download it from https://www.visualstudio.com/vs/mac/ and install it.
Ok. I assume that you have all the prerequisite software installed in your mac.
Now follow the bellow steps.
1. Create an account in Bitbucket (https://bitbucket.org/) if you have not created one before.
2. Create a repository in Bitbucket with your project name. I'll create one as MyAPI because I'm going to host an ASP.Net Core Web API project.
Give a name to your repository and Select No for Include a Readme.
3. Inorder to manage things in git we need a tool.
Since we are using Bitbucket which provides by Atlasian, I'm going to use their git GUI tool called Sourcetree. Go to https://www.sourcetreeapp.com and download it for free.
4. Open Sourcetree app in your mac and go to New --> Clone from URL
4.1. Go to your Bitbucket repository (MyAPI) and copy the repository clone url.
NOTE: Don't copy the 'git clone ' part of the text.
4.2. Paste the copied text inside the 'Clone a Repository' section in Sourcetree.
4.3. Click on Clone.
5. Create a folder called MyAPI_Temp in your mac.
6. Let's create our actually project now.
Open Visual Studio for Mac and create a .Net Core project. In this scenario I have created an ASP.Net Web API project called MyAPI (which has the similar name of our Bitbucket repository).
6.1. Don't select 'Use git for version control' check box.
6.2. Don't give the destination path of the repository that we have just cloned !!!
6.3. Select the path of above mentioned folder (MyAPI_Temp)
6.4. Build your project ignorer to verify it has no build errors.
6.5. Close the solution from Visual Studio.
7. Go to the project folder (MyAPI_Temp) and copy all the content of it.
8. Go to the local repository folder (MyAPI) which was cloned from Bitbucket.
8.1. Paste the content of MyAPI_Temp folder to here.
9. Open Sourcetree and you will see there is an uncommited change.
9.1. Make sure the changes are correct and select all the files that need to be committed.
9.2. Give a commit message and click Commit
10. Push the changes
10.1. Click on Push ison in Souretree
10.2. Select the branch that you have to push and click Ok.
10.3. After the push you will get an success message.
Done.
We have successfully push our project to git repository in Bitbucket.
You can visit Bitbucket MyAPI repository to verify our project has been copied to it.
Work in the MyAPI project
Now we have initialize our project with the git.
But in Visual Studio our project have mapped with non git manage folder (MyAPI_Temp)
So, just delete that folder.
Now when you open your MyAPI project in Visual Studio it will complain there is no MyAPI project so it has to removed from the project list.
Click on Yes.
Now. Open your MyAPI app from Visual Studio by selecting the path to MyAPI folder.
Do a change to a file.
And go to your Souretree to identify your change has been captured by git.
Thats all...
Happy Coding....
Comments
Post a Comment