How to "resync" commits in GitLab after fetching from remote repository? - gitlab

I've created GitLab project by cloning remote repository. During a few days my colleagues pushed their commits to the original repository (not GitLab). Now I did 'git fetch --all' from GitLab repository but commits do not show in GitLab web UI. What should I do to resync GitLab project with its repository? Is there rake task for that? I can't simply recreate the project as we already imported issues from an external source, created labels, milestones, etc.

There is no GitLab feature to fetch the upstream updates. What you did was import an already existing repository, and that is a one time feature.
But you can fetch the upstream updates into your local repository, then push them to GitLab. You'll need to add the orginial/upstream repo as a remote to your local repository by running git remote add upstream {path to original repo}, then fetch the upstream repos by running git fetch upstream, then merge git merge upstream/master, then git push master origin.
GitHub has a decent help section on adding the upstream remote, and doing the merge.

Only the EE version of GitLab has the repository mirroring feature which supports automatically pulling down updates from the import source repository.
If you are using the free CE version, you'll have to manually update or create a custom process.

Related

Gitlab CI semantic release local branch beta behind the remote one

I am using semantic release for handling versioning in my repo. But recently i am facing issues when running the job. I have a beta branch where beta versions are released. But when the changes are added to beta semantic release runs and shows
The local branch beta is behind the remote one, therefore a new version won't be published
Using the debug flag got some more logs
error: failed to push some refs to 'https://username:[secure]#repo_url'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Any idea how this can be resolved

First push for folder with submodules on GitLab

I need to push to GitLab a folder (this will be my repo) that contains several modified gihub repos. What is the best way to do it? As far as I understood, what I should do it
Make a GitLab repo for the main folder
Push the submodules
Push the main module
The content of the .gitmodules file is as follows:
[submodule "restyle"]
path = restyle
url = ./restyle
Once I push the main folder, the submodules are visible on GitLab, but I cannot open them. How can I fix this? I would like to see the actual folder and to be able to open them.
The .gitmodules file you presented contains a circular definition; it says that Git should create a submodule for your repository at path restyle, and should populate that path with a clone of the Git repository at URL ./restyle, which is exactly the same directory. The URL needs to point to a Git repository located outside of the current repository. That is why you are unable to open your submodule.
I recommend the Git Tools - Submodules documentation for a more complete description.
If you want a single monolithic repository instead of a main repository which uses submodules, then your "submodules to simple folders" solution should be fine.
However, if you want to retain the submodule aspect of your existing repository, you will need a .gitmodules file that has appropriate URLs for the source of each of the submodules. If you make changes to a submodule, you have a couple of options:
If your changes would help others, make a pull request at the submodule's origin and get your changes moved upstream.
Once done, pull the updates back into your submodule directory and check out the new commit.
In your main repository top directory, commit the new revision pointer for the updated submodule.
If your changes cannot or should not be incorporated in the original upstream location, then it would be best to clone that upstream repository into your GitLab account/instance and change your submodule to point to your GitLab copy.
Push your changes to GitLab.
In your main repository top directory, commit the new revision pointer for the updated submodule.

How do I resolve merge conflicts using git rebase?

I want to know how I can resolve merge conflict using git rebase? I use gitlab UI to create merge request. Currently its showing "There are merge conflicts". How to get rid of this error on UI so that the administrator of project merges the "merge request" from UI?
I have new branch called "feature/one" which I am trying to merge into "dev" and ran into conflict issue.
Any help, greatly appreaciated.
If you are alone working on the feature/one, you would rebase it on top of dev locally, resolve the conflict there (meaning locally on your machine) and force push.
That is
git switch feature/one
git rebase dev
# resolve conflicts
git push --force
That would update your merge request automatically.

Publish Gitlab artifacts to Artifactory

I want to publish my Gitlab project's(not a maven project) artifact to JFrog Artifactory. The artifact size is 4.2 GB.
I searched for this but mostly got links to publish Gitlab Maven project to Artifactory. My project is not a maven project.
I have a requirement to keep all source code in Gitlab and artifacts(.war, .tar.gz) in Artifactory.
How do I achieve this?
It sounds like you're looking for Git LFS. This is an extention to Git that allows your Gitlab repository to track artifacts without actually storing them in the repository, instead using some external filestore or artifact management server.
Artifactory supports Git LFS repositories, and you can find the documentation for setting it up here.

How to use remote paths in gitlab ci?

I installed GithubHQ in one server and GitlabCI in another server. But now I need do integration between GitlabHQ and GitlabCI. When I go to add a new project in GitlabCI he requests a path .git project, but the project is on another server where the GitlabHQ.
I tried use the path remote, like: http://[domain-name]/[user]/[project].git but he not accept.
I researched about how GitlabCI search the path and found that it does not support remote paths. He use "Rugged::Repository.new(path)" just to get the project on the server.
Does anyone know a way to use paths .git remotes in GitlabCI?
As illustrated by Issue 36:
Actually the purpose of gitlab-ci implies that you install it on deployment point. You install it where you deploy your project
So you are supposed to use a local non-bare repo.
You could, in your case, clone your remote repo on the gitlab-ci server, and use that local path.
In order to build an integration between gitlab and gitlab-ci:
add gitlab_ci user to git group for read access
clone your project via git clone /home/git/repositories to somewhere like /home/gitlab_ci/projects/...
add this project to ci.
setup gitlabhq to use ci service
Thats all.
On gitlab push it will trigger gitlab ci to make git fetch origin, so testing repo will be always up to date.

Resources