Set Up GIT in Visual Studio Code in macOS | Salesforce Developer Guide
Set up GIT in Visual Studio Code
IF you are using Visual Studio Code, you may want to use GIt for version control. Here, we’ll see how to set up Git and connect to bitbucket. This is the step by step process to do so in macOS.
Step -1: Install GIT
First, you have to install GIT, if you are using macOS and you have never used Xcode you can use MacPorts to install GIT. First, install MacPorts and then go to https://www.atlassian.com/git/tutorials/install-git. From here you have to download Git for Mac installer. Then open your system’s terminal (macOS) and check the git version, through the command: git --version.
Step 2- Create your Bitbucket account.
Create your Bitbucket account, after which you have to create a repository, through which you can manage your data. After creating a Repo or repository, you will get a link to clone it in your local system.
For example: Here is the clone link. Copy this link git clone URL and open the terminal.
Don't forget to check out: How to Setup Salesforce on VS Code - Developer Guide
In the terminal, set path of the location where you want to have the repo. Suppose, you have a folder in your desktop named GIT Projects. So you to type cd and drag that folder to the terminal and it will automatically take the path.
Press enter and now you are in your can clone your repo.
Paste the command in the git clone URL. And your repo is now saved in your system. This creates a hidden folder for git, if you wish you can see the hidden folders by command+Shift+. (dot), but always keep this folder hidden.
Step 3: Visual Studio Code
Once, you have cloned your repo in your system, open Visual Studio Code and open project folder which you have cloned, here you can see that the files have a “U” on their right-hand side, it means that the file is not yet read by GIT, for this open terminal in Visual Studio Code and add command line line “git add .”
Now you can see that the “U” is changed to “A” which means that the files are added in git. Next, the step is to commit. The command for this is git commit. But you need to send the message as if what commit you are performing. So, the command for commit along with the message is git commit -m “Initial Commit”.
Check out another amazing blog by Krati here: Salesforce Application Lifecycle Management - Explained
Now, this commit is done in your local system. To save these changes in your bitbucket, you have to push these. Enter “git push” and your changes can be seen in your bitbucket account.
Here, the changes have been saved.
Responses