Supposing that you had a git server, we can use exist git as your own working bare.
[On your own git server] Create a repo.
Clone an exist git.
1 |
$ git clone git@exist-server:exist.git
|
Make its master branch writable.
1 |
$ echo -e "[receive]ntdenyCurrentBranch = ignore" >> exist.git/.git/config
|
[On your client] Create a branch & make a change.
Clone exist.git as your own git-src, in which you can see the old commits and branch.
1
2
|
$ git clone git@your-server:exist.git
$ cd exist
|
We create a new branch based on its master.
1
2
3
4
|
$ git checkout -b mybranch
$ echo "Add README" > README
$ git add README
$ git commit -m "Add READEME in ROOT"
|
Since this is our first commit, we should push our branch to origin. Next time you should just type ‘git push’
1 |
$ git push origin mybranch
|
[On your own git server] An update in master.
Let’s get some new commits.
1 |
$ git pull
|
Here we get something like this…
Now we get commit0 and commitA on mybranch, with commit0 and commit1 on branch master.
What we want is something like this.
[On your client] Merge commit1 to mybranch
Way 1.Just merge them from your own git server
1 |
$ git pull origin master
|
Way 2.Pull commit1 to local master, then rebase or merge it to mybranch
Merge:
1 |
$ git merge master
|
Rebase:
1 |
$ git rebase master
|
Final step:
1 |
$ git push
|
There’s a little difference between merge and rebase in history.
Reference:
http://gitbook.liuhui998.com/4_2.html