git rebase without using a branch
Suppose I am not using branch (I am working on a local master branch, with origin to be master branch on remote server). Wondering what is the function of the command? My confusion is sometimes I see people using this command to merge local changes (with changes on master remote server branch) successfully without using branch, but I could be wrong but I think rebase only works when you are working on a branch (master) and merge with some other branch?
git rebase -i origin/master
origin/master is a branch just like master . It is basically tracks whatever contents are on the remote master.
When you run git fetch from master it will fetch all commits from your remote master and put it onto origin/master . If you then run git rebase -i origin/master , this happens:
origin/master are temporarily put away origin/master master So, if you first manually fetch and then rebase , thats basically manually doing what git pull --rebase would do.
As an aside, you can also rebase onto your own branch, for example: git rebase HEAD~2 . This will let you re-order (or otherwise edit) the commits on your current branch.
下一篇: 没有使用分支的git rebase
