1. Home
  2. How To
  3. Dedicated Server
  4. How To Use Git Basic Commands

How To Use Git Basic Commands

Objectives

Understand and utilize the fundamentals of Git.

Prerequisites

  1. Git installed on your machine (https://git-scm.com/download/)
  2. Visual Studio Code installed on your machine (https://code.visualstudio.com/)

Steps

Step 1: Create An Empty Repository

Go to Visual Studio Code.

Select Terminal / press Ctrl + Shift + `

At the terminal, cd to the destination folder OR mkdir *folder name* to make a new directory / folder.

Use the following command: –

git init
– Initializes the git repository

NOTE: Only use this command in directories that do not contain the .git folder.

Step 2: Pushing a New Project to Gitlab

On your VSC’s terminal, cd to your project directory.

Enter the following command to add the entire project folder into a commit.
git add .

git status
– Displays the state of the working directory and the staging area.

git commit -m ‘My First Commit’
– Saves your changes to your local repository.

git push http://your-project-url.git master
– Pushes the local repository content to a specified remote repository.
NOTE: You can specified to which branch the content will be pushed to.

If it succeeded, the project will be stored in your gitlab project repository.

Step 3: Pulling a Project From Gitlab

On your VSC’s terminal, cd to your project directory.

To retrieve the remote repository content to your local repo, you can do so with the following commands: –
git pull http://your-project-url.git
OR
git clone http://your-project-url.git

If it succeeded, the latest version of the project will be stored in your local repository.

Updated on July 8, 2020

Was this article helpful?

Related Articles

Need Help?
Submit a ticket to us and let our professional team assists you

Support Billing Sales
Support
Billing
Sales