How to add local folder to a GitLab project

How to add local folder to a GitLab project

GitLab is an open source application used to code, test and deploy code together. It provides the Git repository management with access controls, code reviews, issue tracking and activity feeds. This tutorial will explain about the process of adding local folder to a GitLab project.

Configuration procedure

To start the configuration procedure, first move to the local folder of the Git using the cd command.

[user1@localhost Desktop]$ cd git/

Run the Git init command to initialize Git repository in the target system.

[user1@localhost git]$ git init
Initialized empty Git repository in /home/user1/Desktop/git/.git/

Add the project path in which the local folder is to be copied and execute the command.

[user1@localhost git]$ git remote add origin git@192.168.7.212:user1/sample-project.git

Now add the files to the list which has to be tracked. To add the whole files give “ .”

[user1@localhost git]$ git add .

Run the Git commit command to list the files that has to be pushed.

[user1@localhost git]$ git commit -m ' 1st commit' 
[master (root-commit) c2bf8c4] 1st commit
 Committer: user1 < user1@localhost.localdomain> 
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
.
.
.
create mode 100755 public_html/test-svgs/flag.svg
 create mode 100755 public_html/test-svgs/github.svg
 create mode 100755 public_html/test-svgs/save.svg
 create mode 100755 public_html/test-svgs/svgo-logo.svg
 create mode 100755 public_html/test-svgs/tiger.svg

Now execute the following command to push the files to the project.

[user1@localhost git]$ git push -u origin master
Counting objects: 213, done.
Compressing objects: 100% (197/197), done.
Writing objects: 100% (213/213), 717.83 KiB, done.
Total 213 (delta 19), reused 0 (delta 0)
remote: Resolving deltas: 100% (19/19), done.
To git@192.168.7.212:user1/sample-project.git
 * [new branch]      master ->  master
Branch master set up to track remote branch master from origin.

Wasn' t that an easy configuration procedure? Now adding local folder to a GitLab project is easy.

Tag : gitlab
Comment
linuxhelp
Oct 29 2019
To add a different folders on Gitlab using different branches.

For example ,I do have branches named test1 test2

First convert the branch from master branch to test1 branch
'git checkout test1'
From test1 branch, I am pushing the data to the origin

git add .

git commit -m "test1 Commit"

git push origin test1

Now again change the branch from test1 to test2 using the git checkout and follow the same procedures where while pushing the origin,change the tes1 as test2
angelaveselinova
Jun 13 2019
how to add a few folders on gitlab in a different branches?
Add a comment
FAQ
Q
how to push the Files in git?
A
To push the Files in git use the following command

git push -u origin master
Q
What is the command to commit a git?
A
Run the Git commit command to list the files that has to be pushed.

git commit -m ' 1st commit'
Q
How to start the git from terminal ?
A
Run the Git init command to initialize Git repository in the target system.

git init
Q
how to Add the new gitlab remote to your existing repository and push ?
A
To Add the new gitlab remote to your existing repository and push use the following command #git remote add gitlab url-to-gitlab-repo
#git push gitlab master
Q
How to remove a directory from git repository?
A
To remove a directory from git repository run the following command
git rm -r one-of-the-directories
git commit -m "Remove duplicated directory"
git push origin (typically 'master', but not always)