SpringBoot #4: Synchronize Visual Code with Gitlab

For the GUI-user like me, using full command prompt is a quiet awkward haha Because I have no idea where to start. I am not book-type person, I don’t like reading. What I like is exploring the tools, even if I don’t know anything about the tools. So in GUI, I can try the menu one by one. But in terminal. I cannot just try it and execute it right haha

However, git command give me an helpful instruction. Open the help instruction from cmd terminal.

git help

If you read it carefully, you will find what to do first.

If you want to create Git repository locally, you may execute this command. This command is to create an empty Git repository or reinitialize an existing one.

git init

Personally, since I use Gitlab as my Git server, I just need to clone the existing one. So run this command instead. Before run the command, make sure the folder path is the path where you want to save the git repository locally.

git clone [Gitlab Repo URL]

You might find the URL on your Gitlab repository homepage

Now you have connected to Gitlab repository. Now how to synchronize the project.

Push Code

Position the terminal inside the git repository path.

Config the username and email address for accessing the Gitlab using following command

git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

Create a new project and generate the project folder inside this repository. Once created, lets try to push it to Gitlab. Go to the active project directory in cmd terminal. Then commit it using this command

git add .
git commit
git push [repository url]

In the terminal, you will be asked to write the push commit message. Insert your message and save it using :wq command line.

You may check the gitlab server now. 😀

Whenever you have change in your code, do the above step to commit and push into gitlab.

To see the changes between your local workspace and gitlab repository, use following command.

git diff

Pull Code

If some of your teams did some changes in the code. You can synchronize the code by pulling the code. You may check it first using the diff command first. Then you can pull it

git pull

Happy Collaborating~ 😀

 

%d bloggers like this: