Git User Guide
We will use git which is a distributed version control and source code management system to submit our code, here is the submission method.
 

Step1:

Enter the following command in the terminal:

$git config --global user.name “your_name”

$git config --global user.email “your_email”

User name and email are used to set your own user name and contact information( user.name and user.email must be completed because these will be used when submitting the repository).

 

Tips:

You can read the user manual by enter " git help " command when you are confused, command as follows:

$git help <command>

 

Step2:

Create a new repository by two ways, here we go

(1) The first way is clone a repository which is already exists from remote Server to local:

$git clone http://user_name@domain/repo_path.git

The "domain" in the command means the server's domain name(the domain name in Trustie system is 222.247.54.100), "repo_path.git" is the relative path(this address will be given in Trustie)

 

(2) Initialize a repository on the local, we named repository as “DEMO” for example, use the directory "/path/to/my/workspace" as a root of personal workspace.

Enter the directory, execute the "git init" command to create the repository.

           $cd /path/to/my/workspace

           $mkdir demo

           $cd demo

           $git init 

 

 

After completed these operation, you can see "git init " command creates a hidden directory in the workspace and this hidden directory is the git repository.

 

Step3:

Submit the file to the local repository:

$git add file1 file2 

"file1" is the file which is already modified, multiple files separated by spaces.

$git commit –m "commit message" 

commit message”is a submission instructions which is a mandatory requirement in the Git, you can use "git log" to list the commit log.

 

Step4:

Push the local branches to the remote repository:

The operation we mentioned above is only to establish a local git repository, we can push it to the remote server in order to work together in the future.

$git remote add origin http://user_name@domain/repo_path.git 

In Git, we call remote repository as origin

$git push origin master 

Push the local master branch to the origin master branch .

 

Step5:

Get the latest branch from the remote repository:

When your team members push the code to the server, we can use "git pull " (or "git fetch") to obtain the modified code.。

$git pull origin master

Pull the remote master branch to the local master branch.

 
--By Trustie Team