Skip to main content

Workflow using git

Install git on your machine:

See Git installation guide.

Create and setup your gitlab account:

To create a gitlab acount see Gitlab Sign Up.

In the settings tab add your SSH key to your gitlab account. If you don't have a ssh key see Learn how to create a SSH key.

Clone a repository into a new local directory:
	[user@fedora ~]$ mkdir my_repo 
	[user@fedora ~]$ cd my_repo
    [user@fedora my_repo]$ git clone git@git01.ncg.ingrid.pt:lip-computing/project_name.git
Create a new branch to work on a new feature:
	[user@fedora my_repo]$ cd project_name
    [user@fedora project_name]$ git branch <name_of_branch>
	[user@fedora project_name]$ git checkout new_feature 
	Switched to branch 'new_feature'  
Push your changes to the remote repository
    [user@fedora project_name]$ git add new_feature.py
    [user@fedora project_name]$ git status
    On branch new_feature
    Changes to be committed:
      (use "git restore --staged <file>..." to unstage)
        new file:   new_feature.py

At this point your changes were added to the staging area. First commit your changes and push them to the remote repository so that other team members can review them.

    [user@fedora project_name]$ git commit -m "<your_commit_message>"
    [new_feature f8ebb26] <your_commit_message>
 	Author: User <user@lip.pt>
 	1 file changed, 1 insertion(+), 1 deletion(-)
    [user@fedora project_name]$ git push origin new_feature
    Enumerating objects: 7, done.
    Counting objects: 100% (7/7), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (4/4), done.
    Writing objects: 100% (6/6), 625 bytes | 625.00 KiB/s, done.
    Total 6 (delta 2), reused 0 (delta 0), pack-reused 0
    remote: 
    remote: To create a merge request for new_feature, visit:
    remote:   https://gitlab.com/user/project_name/-/merge_requests/new?merge_request%5Bsource_branch%5D=new_feature
    remote: 
    To gitlab.com:user/project_name.git
     * [new branch]      new_feature -> new_feature