Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to move a commit from one repo to another repo #6595

Open
1 task
JessicaLucindaCheng opened this issue Apr 8, 2024 · 32 comments
Open
1 task

How to move a commit from one repo to another repo #6595

JessicaLucindaCheng opened this issue Apr 8, 2024 · 32 comments
Assignees
Labels
2 weeks inactive An issue that has not been updated by an assignee for two weeks Complexity: Medium documentation Documentation creation Feature: Wiki role: dev leads Tasks for technical leads size: 1pt Can be done in 4-6 hours

Comments

@JessicaLucindaCheng
Copy link
Member

JessicaLucindaCheng commented Apr 8, 2024

Overview

We need to write instructions for how to move a commit from one repo to another repo so that leads at Hack for LA can move files between repos when needed.

Action Items

  • In a new comment below, write instructions for how to move a commit from one repo to another repo.

Resources/Instructions

@JessicaLucindaCheng

This comment was marked as resolved.

@JessicaLucindaCheng
Copy link
Member Author

JessicaLucindaCheng commented Apr 10, 2024

[WIP DRAFT] How to move a commit from one repo to another using cherry-pick

These instructions were adapted from Elliot Blackburn's Moving a git commit from one repository to another.

Prerequisites

  • You know how to or can figure out how to
    • find a commit SHA,
    • use git commands,
    • fork a repository (repo),
    • clone the forked repo onto your computer, and
    • create a new branch based on an existing branch.

Notes

  • If you are trying to preserve author history when moving a file to another repo, the following instructions will only work if you want to move a file with only one commit in its history.
  • The instructions are written to adhere to the workflow on the Hack for LA Website Team.

Assumptions

  1. You are using GitHub to host your remote repositories.
  2. The repository for where the commits will come from and the repository for where the commits will be moved to exist already or have been created. Also, the repositories have at least one branch, such as the main or master branch.
  3. You have Git installed on your local machine. If you need instructions on how to install Git on your local machine, see section 1.2 Dev setup (2): Installing Git from the Hack for LA Website Team's CONTRIBUTING.md file.

Instructions

A. Copy Commits From One Repository to Another

Forking and Cloning Repositories

On GitHub, do the following

  1. Fork the repo where you want to copy the commits to 1. For these instructions, I will refer to this as the forked new repo.
  2. In your forked new repo, create a new branch based on the branch you want to work off of, such as the main or master branch 2. I will refer to this as the working branch and this will be the branch you push your work to.
  3. Fork the repo where you have the commits currently 1. For these instructions, I will refer to this as the forked old repo.
  4. Clone a copy of your forked old repo to your local machine 3.
  5. For the commit(s) you want to copy, find the commit(s) SHA. There are multiple ways to find the commit SHA, including on GitHub or locally on your computer 4.

On Your Local Machine, Copy Commits

  1. On your local machine, in your forked old repo, add a remote that will fetch and push to your forked new-repo 56.
    git remote add [FORKED-NEW-REPO-NAME] https://github.com/[GITHUB-HANDLE]/[FORKED-NEW-REPO-NAME].git
    
    • Replace [FORKED-NEW-REPO-NAME| with the name of your remote forked new repo.
    • Replace [GITHUB-HANDLE] with your GitHub handle.
    • Replace [FORKED-NEW-REPO-NAME| with the name of your remote forked new repo.
  2. Fetch your forked new repo 7.
    git fetch [FORKED-NEW-REPO-NAME]
    
    • [FORKED-NEW-REPO-NAME| is the name of your remote forked new repo.
  3. Create a local branch based on your forked new repo's working branch 58.
    git checkout -b [WORKING-BRANCH-NAME] --track [FORKED-NEW-REPO-NAME]/[WORKING-BRANCH-NAME]
    
    • [WORKING-BRANCH-NAME] should be replaced with the name of your forked new repo's working branch.
    • [FORKED-NEW-REPO-NAME] should be replaced with the name of your forked new repo.
  4. Cherry-pick the commit you want to copy 59.
    git cherry-pick [COMMIT-SHA]
    
    • [COMMIT-SHA] should be replaced with the commit SHA.
  5. If you have more commits to copy, repeat steps 8 and 9.
  6. Push cherry-picked commit to the new-repo 510.
git push [FORKED-NEW-REPO-NAME] [WORKING-BRANCH-NAME]
  • [FORKED-NEW-REPO-NAME] should be replaced with the name of your remote forked new repo.
  • [WORKING-BRANCH-NAME] should be replaced with the name of your forked new repo's working branch.

Create a Pull Request

  1. When creating your pull request 11,
  • Base repository should be the original repo where you want to copy the commits to.
  • Base should be the branch where you want to copy the commits to.
  • Head repository should be your forked new repo.
  • Compare should be your forked new repo's working branch.
  • Example:
    [REDO IMAGE WITHOUT ANNOTATIONS]

Merge the pull request

[ADD INSTRUCTIONS HERE]

  • I recommend using rebase merging to preserve who authored the file.
  • To see examples of the commit history of the various methods of merging, see these branches in my forked repo:

B. Remove files from the old repo

Delete the files
[ADD INSTRUCTIONS HERE]

Resources

Footnotes

  1. Forking a repository 2

  2. Creating a branch via the branches overview

  3. Cloning your forked repository

  4. Finding a commit's SHA

  5. Moving a git commit from one repository to another 2 3 4

  6. Adding a remote repository

  7. git fetch

  8. git checkout

  9. git cherry-pick

  10. git push

  11. Creating a pull request from a fork

@JessicaLucindaCheng JessicaLucindaCheng changed the title How to move a commit from one repo to another How to move a commit from one repo to another repo Apr 10, 2024
@JessicaLucindaCheng

This comment was marked as outdated.

@github-actions github-actions bot added the To Update ! No update has been provided label Apr 26, 2024

This comment has been minimized.

@github-actions github-actions bot removed the To Update ! No update has been provided label May 3, 2024

This comment has been minimized.

@github-actions github-actions bot added the 2 weeks inactive An issue that has not been updated by an assignee for two weeks label May 3, 2024
@JessicaLucindaCheng

This comment was marked as outdated.

@JessicaLucindaCheng JessicaLucindaCheng added Status: Updated No blockers and update is ready for review and removed 2 weeks inactive An issue that has not been updated by an assignee for two weeks labels May 5, 2024
@github-actions github-actions bot added To Update ! No update has been provided and removed Status: Updated No blockers and update is ready for review labels May 10, 2024

This comment has been minimized.

@github-actions github-actions bot added 2 weeks inactive An issue that has not been updated by an assignee for two weeks and removed To Update ! No update has been provided labels May 24, 2024

This comment has been minimized.

This comment has been minimized.

@HackforLABot

This comment has been minimized.

@JessicaLucindaCheng

This comment was marked as outdated.

@JessicaLucindaCheng JessicaLucindaCheng added Status: Updated No blockers and update is ready for review and removed 2 weeks inactive An issue that has not been updated by an assignee for two weeks labels Oct 7, 2024
@HackforLABot HackforLABot added To Update ! No update has been provided and removed Status: Updated No blockers and update is ready for review labels Oct 11, 2024
@HackforLABot

This comment has been minimized.

@HackforLABot HackforLABot added 2 weeks inactive An issue that has not been updated by an assignee for two weeks and removed To Update ! No update has been provided labels Oct 25, 2024
@HackforLABot

This comment has been minimized.

@JessicaLucindaCheng

This comment was marked as outdated.

@JessicaLucindaCheng JessicaLucindaCheng added Status: Updated No blockers and update is ready for review and removed 2 weeks inactive An issue that has not been updated by an assignee for two weeks labels Oct 28, 2024
@HackforLABot HackforLABot removed the Status: Updated No blockers and update is ready for review label Nov 1, 2024
@HackforLABot

This comment has been minimized.

@HackforLABot HackforLABot added the To Update ! No update has been provided label Nov 8, 2024
@HackforLABot HackforLABot added 2 weeks inactive An issue that has not been updated by an assignee for two weeks and removed To Update ! No update has been provided labels Nov 15, 2024
@HackforLABot

This comment has been minimized.

@JessicaLucindaCheng JessicaLucindaCheng added the To Update ! No update has been provided label Nov 17, 2024
@JessicaLucindaCheng
Copy link
Member Author

JessicaLucindaCheng commented Nov 17, 2024

Issue Progress Update

Tasks

  • Note: cherry-pick only moves the specific commit and not the whole history
  • Will cloning both repos at beginning, remove need to git fetch new repo later?
  • Way to directly cherry-pick items into a specific folder? Or need to work on moving files on the branch after pushing commits to remote? Or separate issue?

@JessicaLucindaCheng JessicaLucindaCheng added Status: Updated No blockers and update is ready for review and removed To Update ! No update has been provided 2 weeks inactive An issue that has not been updated by an assignee for two weeks labels Nov 17, 2024
@HackforLABot HackforLABot removed the Status: Updated No blockers and update is ready for review label Nov 22, 2024
@ExperimentsInHonesty
Copy link
Member

create an issue here to make a new guide https://github.com/hackforla/knowledgebase-content/issues/new/choose

@HackforLABot
Copy link
Contributor

@JessicaLucindaCheng

Please add update using the below template (even if you have a pull request). Afterwards, remove the '2 weeks inactive' label and add the 'Status: Updated' label.

  1. Progress: "What is the current status of your project? What have you completed and what is left to do?"
  2. Blockers: "Difficulties or errors encountered."
  3. Availability: "How much time will you have this week to work on this issue?"
  4. ETA: "When do you expect this issue to be completed?"
  5. Pictures (optional): "Add any pictures of the visual changes made to the site so far."

If you need help, be sure to either: 1) place your issue in the Questions/In Review column of the Project Board and ask for help at your next meeting, 2) put a "Status: Help Wanted" label on your issue and pull request, or 3) put up a request for assistance on the #hfla-site channel. Please note that including your questions in the issue comments- along with screenshots, if applicable- will help us to help you. Here and here are examples of well-formed questions.

You are receiving this comment because your last comment was before Monday, December 30, 2024 at 11:04 PM PST.

@HackforLABot HackforLABot added the 2 weeks inactive An issue that has not been updated by an assignee for two weeks label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 weeks inactive An issue that has not been updated by an assignee for two weeks Complexity: Medium documentation Documentation creation Feature: Wiki role: dev leads Tasks for technical leads size: 1pt Can be done in 4-6 hours
Projects
Status: In progress (actively working)
Development

No branches or pull requests

3 participants