how to add clone git to my own created repo in gitlab - gitlab

How to take the project from one repo (where I've been given developer rights by some other person who is the master) to my own created repo (where I'm the master). I'm able to use both CMD and webstorm IDE for accessing GIT.

The action you want to perform is called 'fork' in the context of source code management (e.g git). Quoting https://docs.gitlab.com/ee/gitlab-basics/fork-project.html:
A fork is a copy of an original repository that you put in another namespace where you can experiment and apply changes that you can later decide whether or not to share, without affecting the original project.
To fork a project in GitLab, you just have to click on the 'fork' button on the project's main page.
You can read detailed steps on https://docs.gitlab.com/ee/user/project/repository/forking_workflow.html#creating-a-fork

Related

Newbie GIT Help - Making a second Repository

I currently work on solutions / projects within a single GIT repository, in Visual Studio. The commits I make are to a local folder on the Visual Studio server, and then I use the command 'git push origin master' (after having changed directory to my local folder / repository) to push commits to a Gitlab in my company's corporate space. The purpose of this is less about using branches and software development (as I am the only person who does any work on this), and more about having a way to rollback changes and keep a master copy off the server.
I now want a fresh copy of this GIT repository, so I can use that as a new baseline for an application migration. I will still continue to work on the existing repository too.
What is the best way to make a copy of the existing repository, that I can treat as a totally separate thing, without accidently messing up my existing config on the server? Should I do the clone from the Gitlab? Or clone locally and then push that up to the new space in my Gitlab? Honestly, I'm a bit confused at this point about the proper model for this stuff.
....................
Sounds like you'd like to fork the project: keep the existing repo and start a new, separate repo based on the old one.
Browse to your project in Gitlab
On the main repo screen, click "fork" in the top right
Select a new/ the same organisation as you'd like
The project is now forked!
From here, you can clone the fork to your local machine in a new folder. These are now separate projects, and code updates can be added, committed and pushed to the separate repos.

How to merge a Git branch using a different identity?

We are using Git for a website project where the develop branch will be the source of the test server, and the master branch will serve as the source for the live, production site. The reason being to keep the git-related steps (switching branches, pushing and pulling) to a minimum for the intended user population. It should be possible for these (not extremely technical) users to run a script that will merge develop into master, after being alerted that this would be pushed to live. master cannot be modified by normal users, only one special user can do the merge.
This is where I'm not sure how to integrate this identity change into my code below:
https://gist.github.com/jfix/9fb7d9e2510d112e83ee49af0fb9e27f
I'm using the simple-git npm library. But more generally, I'm not sure whether what I want to do is actually possible as I can't seem to find information about this anywhere.
My intention would be of course to use a Github personal token instead of a password.
Git itself doesn't do anything about user or permission management. So, the short answer is, don't try to do anything sneaky. Rather, use Github's user accounts they way they were intended.
What I suggest is to give this special user their own Github account, with their own copy of the repo. Let's say the main repo is at https://github.com/yourteam/repo, and the special repo is at https://github.com/special/repo.
The script will pull changes from the team repo's develop branch, and merge this into it's own master branch and push to https://github.com/special/repo.
Then, it will push its changes to the team's master branch. This step can optionally be a forced push, since no one else is supposed to mess with master, anyway. (In case someone does, using a forced push here means they have to fix their local repo to match the team repo later on, rather than having the script fail until someone fixes the team repo.)
At the same time, your CI software will notice that master has changed at https://github.com/special/repo, and will publish as you normally would. This is the linchpin: the CI doesn't pay attention to the team repo, so although your team has permission to change it, those changes don't make it into production.
This special user will need commit access to the team repo, in addition to its own GitHub repo. The easiest way is probably to use an SSH key, and run the git push command from the script, rather than trying to use the GitHub API.

How to update repository with built project?

I’m trying to set up GitLab CI/CD for an old client-side project that makes use of Grunt (https://github.com/yeoman/generator-angular).
Up to now the deployment worked like this:
run ’$ grunt build’ locally which built the project and created files in a ‘dist’ folder in the root of the project
commit changes
changes pulled onto production server
After creating the .gitlab-ci.yml and making a commit, the GitLab CI/CD job passes but the files in the ‘dist’ folder in the repository are not updated. If I define an artifact, I will get the changed files in the download. However I would prefer the files in ‘dist’ folder in the to be updated so we can carry on with the same workflow which suits us. Is this achievable?
I don't think commiting into your repo inside a pipeline is a good idea. Version control wouldn't be as clear, some people have automatic pipeline trigger when their repo is pushed, that'd trigger a loop of pipelines.
Instead, you might reorganize your environment to use Docker, there are numerous reasons for using Docker in a professional and development environments. To name just a few: that'd enable you to save the freshly built project into a registry and reuse it whenever needed right with the version you require and with the desired /dist inside. So that you can easily run it in multiple places, scale it, manage it etc.
If you changed to Docker you wouldn't actually have to do a thing in order to have the dist persistent, just push the image to the registry after the build is done.
But to actually answer your question:
There is a feature request hanging for a very long time for the same problem you asked about: here. Currently there is no safe and professional way to do it as GitLab members state. Although you can push back changes as one of the GitLab members suggested (Kamil Trzciński):
git push http://gitlab.com/group/project.git HEAD:my-branch
Just put it in your script section inside gitlab-ci file.
There are more hack'y methods presented there, but be sure to acknowledge risks that come with them (pipelines are more error prone and if configured in a wrong way, they might for example publish some confidential information and trigger an infinite pipelines loop to name a few).
I hope you found this useful.

Gitlab repository vs project vs submodule

I started exploring Gitlab for version control management and I got an issue at the first step itsself. When ever I create a project its creating a new repository. I have few webapplications which are independent to each other. In that case do I need to use different repository for every project.
What I am looking for is what is what and when to use what but not able to find what is repository and what is project in gitlab website as well as through other sources as well.
Also I came across a term submodule, when can it be used. Can I create one global project and have all the webapplications as different submodules.
Can any one please help me in understanding the difference between those 3 and when to use what based on their intended way of usage. Also please help me by pointing to a good learning site where I can get the information of doing basic version control operations in gitlab.
Thanks.
Gitlab manages projects: a project has many features in addition of the Git repo it includes:
issues: powerful, but lightweight issue tracking system.
merge requests: you can review and discuss code before it is merged in the branch of your code.
wiki: separate system for documentation, built right into GitLab
snippets: Snippets are little bits of code or text.
So fear each repo you create, you get additional features in its associated project.
And you can manage users associated to that project.
See GitLab documentation for more.
The Git repo and Git submodule are pure Git notions.
In your case, a submodule might not be needed, unless you want a convenient way to remember the exact versions of different webapp repo, recorded in one parent repo.
But if that is the case, then yes, you can create one global project and have all the webapplications as different submodules.
Each of those submodules would have their own GitLab project (and Git repo).

Setup read-only vendor SVN repository as mirror/external within my own repository

Currently I am working on opencart site and I would like to integrate opencarts source into my own SVN (https://github.com/opencart/opencart).
The goal is to be able to make my own customizations to core OpenCart files and then, when a new version of open cart is released, integrate there changes into my local version.
I was thinking of source structure as follows:
/trunk/opencart - my custom version of open cart
/vendor/opencart - the current opencart trunk.
The intended workflow would be to pull the latest open cart from their servers, then perform a local merge into my trunk. Currently, I have been struggling to set this up correctly as I am very new to SVN and TortoiseSVN.
My current setup, is Windows7 running TortoiseSVN 1.8.0, Build 24401 - 64 Bit. On my local server I have Ubuntu 13.04 64bit with svn, version 1.7.5 (r1336830).
I managed to setup repository that I can check into and out of, and created an external reference in vendor folder using externals. But I’m struggling to generate the main trunk from this external data. When I try to branch from vendor/opencart to trunk/opencart, it attempts to generated that branch on https://github.com/opencart/opencart rather than my local server. (This rightly fails as the repository is read only).
If I try to perform a merge in SVN on the empty trunk/opencart folder with vendor/opencart I also get problems as there is lack of ancestry in the trunk folder. I've read multiple sources - some say to use my approach, some say I should be using svnsync.
What is the best/simplest approach? Ideally, I would like SVN to pull the latest source, rather than dumping the source into a separate folder.
Re-read about svn:externals in Subversion
Get Subversion URL for this Git repository (SVN can't directly communicate with Git) - it's "Subversion checkout URL" in sidebar, open it in Repo-browser and select needed subtree for you - it can be some branch or trunk, remember full URL to needed subtree (it can be, f.e., https://github.com/opencart/opencart/trunk/upload)
Define, where in your repository you want to mount external repo (let it be /vendor/opencart URL)
Checkout parent of mount-point (or parent of parent for our case, if parent still doesn't exist) into new unrelated to work, Working Copy
Create in WC root new folder (usual, ordinary, standard) vendor
For folder vendor add new svn-propery svn:externals in TSVN's wizard
Commit changes
Check results
PS: you can see (checkout, inspect) at this URL https://subversion.assembla.com/svn/subversion-troubleshoot-b/trunk as sample of simplest use-case for externals (subdirectory lib in trunk is svn:external to another repository subtree)
PPS: At staring point you trunk can be empty, you merge /vendor/opencart in order to get initial vanilla state of code in trunk for your own changes on top of it

Resources