element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Software
  • Products
  • Dev Tools
  • Software
  • More
  • Cancel
Software
Forum Github Template repository: get updates from origin
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Software to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 4 replies
  • Subscribers 26 subscribers
  • Views 1808 views
  • Users 0 members are here
  • tutorial
  • github
  • version_control
  • learning
  • git
  • gitlab
  • github_repository
Related

Github Template repository: get updates from origin

Jan Cumps
Jan Cumps over 1 year ago

When you create a Github repository from a Template, there is no origin <> destination relationship. They live separate lives. This is different from Forking a repository. In that case the fork knows its origin, and you can sync your Fork from the origin.

I would like to update my repository from the original template though. Because that repository gets bug fixes, and I want to inherit them.

  • The Original template repo: https://github.com/jancumps/pst_rtos
  • My repository that's based on that template: https://github.com/jancumps/pst_rtos_xiao

I have been looking for solutions. I found a few custom Github actions that can do this. But they fail if there's a merge conflict. And because it's a job, you can't interactively resolve that. Then I found a solution on Stack Overflow that uses the git command. It worked for me:

I'm looking for feedback. Do you think that this will corrupt the pst_freertos_xiao repo?
The Stack Overflow page lists the side effects, and I've read them. It also has different suggestions, e.g.: patching ...

I started a command line, and navigated to the root of pst_rtos_xiao repository clone on my hard disk.

Then I executed these commands:

$ git pull

image

$ git remote add template https://github.com/jancumps/pst_rtos.git

image

$ git fetch --all

image

$ git merge template/main --allow-unrelated-histories

image

If merge conflicts occcur, this would be where you fix them.

$ git status

image

$ git add CMakeLists.txt

$ git add source/scpi/scpi-def.h

image

$ git commit -a -m "refreshing from template"

image

$ git push

image

This merged all changes in my oinline Github repo https://github.com/jancumps/pst_rtos_xiao. That was the goal.

image

  • Sign in to reply
  • Cancel

Top Replies

  • embeddedguy
    embeddedguy over 1 year ago +1
    I do not know if I am right or wrong but merge conflict occurs if you push something upstream without first pulling the master branch/head of a particular repo. Also, while pulling you need to stash…
  • embeddedguy
    embeddedguy over 1 year ago in reply to Jan Cumps +1
    But I think git is smart nowadays, if it thinks there is something not updated during push or pull, it will give some form of error or warnings. If someone still ignores it by doing force pull, then…
  • embeddedguy
    embeddedguy over 1 year ago

    I do not know if I am right or wrong but merge conflict occurs if you push something upstream without first pulling the master branch/head of a particular repo.

    Also, while pulling you need to stash your local changes and then do the merge manually. 

    Then it will work...A bit complex process that I forget and repeat some exercise to remind myself.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to embeddedguy

    Stashing, I try to avoid by only doing this activity when my local repository is in sync with the online one.

    Then I only need to focus on what changed in the template.

    Merge conflicts happen if the source is changed on both sides, and git can't figure out how to merge them together.

    I think that in case of merging template changes to a derived repo, the chances of having that are fairly high. But the future will tell...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • embeddedguy
    embeddedguy over 1 year ago in reply to Jan Cumps

    But I think git is smart nowadays, if it thinks there is something not updated during push or pull, it will give some form of error or warnings.

    If someone still ignores it by doing force pull, then surely, there will be conflict.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to embeddedguy

    It's those merge warnings (errors) that I want. Because I'll have to resolve those to keep the downstream project working, without overriding changes over there ...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube