4

I have forked project A in GitLab and create B and made some modification. After a month now i would like to update B project by pulling changes done in A.

How can i do this? I have option to create Merge request but i could't able pull from A.

I know this could be very simple because if anyone like to contribute has eventually take pull before submitting merge request.

Please help. I found only this https://about.gitlab.com/2016/12/01/how-to-keep-your-fork-up-to-date-with-its-origin/

Basically i want to "Pull new updates from original GitLab repository into forked GitLab repository"

abbas.aniefa
  • 2,855
  • 21
  • 30
  • Possible duplicate of [How do I update a GitHub forked repository?](https://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository) – rpadovani Feb 28 '18 at 15:02
  • Thanks. That answer really helped me to find much easier solution. – abbas.aniefa Mar 02 '18 at 04:35

3 Answers3

2

I found an option to update my forked project via Android Studio. It may help some android developers.

I have added new Remote URL via Git -> Add Remote and named as upstream. Now i have done a fetch (Git -> Fetch) and found both Project A and Project B branches.

Now i can easily update my Project B using Merge request and pushed to origin.

abbas.aniefa
  • 2,855
  • 21
  • 30
0

With GitLab 16.0 (May 2023), you now can (only for Premium or Ultimate):

Update your fork from the GitLab UI

Managing your fork just got easier. When your fork is behind, select Update fork in the GitLab UI to catch it up with upstream changes. When your fork is ahead, select Create merge request to contribute your change back to the upstream project. Both operations previously required you to use the command line.

See how many commits your fork is ahead (or behind) on your project’s main page and at Repository > Files. If merge conflicts exist, the UI gives guidance on how to resolve them using Git from the command line.

https://about.gitlab.com/images/16_0/fetch_new_upstream_contents_when_fork_is_behind.png -- Update your fork from the GitLab UI

See Documentation and Issue.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

If you don't have Gitlab Premium (so mirroring is not possible) - you can use a shell function in your ~/.bashrc or ~/.profile (busybox shell)

gitpull () {
        git checkout master
        git fetch upstream
        git pull upstream master
        if [ $? = 0 ]; then
                printf "\ngit fetched into master ok: pushing => fork (origin)\n\n"
                git push origin +master
        fi
}
Stuart Cardall
  • 2,099
  • 24
  • 18