I have a repository based on "https://github.com/MicrochipTech/amazon-freertos.git", I have pushed this to my own repository, which is not in Github so I believe fork is not possible. In my newly created copy I have added my application files as well as some changes to the amazon source files. This is committed and pushed to my private repository.
When the amazon repository eventually changes, is there some way that I can merge those changes into my repository, yet keeping the changes i have made to the previous version of that repository? Note that I will have modified some of the files that are part of the amazon repository so I cannot simply have it as a submodule.
Edit: As suggested I have:
git clone -b mchpdev_20210700 --origin microchip --origin microchip https://github.com/MicrochipTech/amazon-freertos.git
cd amazon-freertos
git remote add origin https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/my-amazon-freertos
H:\dev\test\amazon-freertos>git remote -v
microchip https://github.com/MicrochipTech/amazon-freertos.git (fetch)
microchip https://github.com/MicrochipTech/amazon-freertos.git (push)
origin https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/my-amazon-freertos (fetch)
origin https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/my-amazon-freertos (push)
H:\dev\test\amazon-freertos>git remote show origin
* remote origin
Fetch URL: https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/my-amazon-freertos
Push URL: https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/my-amazon-freertos
HEAD branch: (unknown)
H:\dev\test\amazon-freertos>git push
Username for 'https://github.com':
H:\dev\test\amazon-freertos> git push origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/my-amazon-freertos'
Looks like the push is going to Github rather than my repository now, I need to repoint it to my repo somehow. If I specify origin master I get the above error message
Edit: Following the commands above and committing with git push origin HEAD:master
, I successfully uploaded the remote microchip repo as well as my own files to my own private repo and I am also able to pull changes from microchip repo, but pending verification on how it will work once there are updates there.
You can have multiple git remotes and pull in changes from either of them.
You can clone the original repository with a custom remote name, eg:
git clone --origin microsoft git@github.com:MicrochipTech/amazon-freertos.git
Then add your own remote:
git remote add origin git@<your-repository>.git
After making custom commits and your repository, you can pull in the latest changes from the original repository by specifying the remote after git pull
:
git pull microsoft master # Pull from original repository
Git will merge the original repository's changes into yours. You will be prompted to fix merge conflicts if there are any.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.