I have setup a git repository for some days. Now I found my start point is some work based on an original release. I hope to add the original release as the first commit and all the my current commit tree is based on it. Is it possible? The current git revision:
A---B---C---D master
I hope to insert one commit at the beginning
O---A---B---C---D master, so that I could use rebase to generate such branch
O---A---B---C---D master
\\---D' my_rebase_branch
Maybe you could try it as below:
1. create a new branch called base_work for the original release branch
2. create a new branch called others_work for your start point
3. suppose your current work branch is my_work. Try the following command:
git rebase --onto base_work others_work my_work
The command will let your work based on base_work, instead of others_work.
If you want to recreate your commits on top of existing commits of an existing repo, you would need to import that repo first before the rebase:
cd /path/to/your/repo
git remote add original /url/original/repo
git fetch original
Then you can rebase, using the --root
option :
git checkout master
git rebase --onto original/master --root master
If " original
" does not exist, you can create it as long as you have access to the content (source code) of said release:
cd /path/to/original/source/code/of/release
git init .
git add .
git commit -m "original release source code"
Then, go back to your own repo, and repeat the command I mentioned (no need for rebase --onto
here)
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.