This is a post for myself, recording my experience with learning how to use git with
(1) multiple remote repositories and
(2) see the content of a previous commit.
(1) Git add a new remote, name it as “upstream”, so now I have two remotes “origin” and “upstream”.
when I need to get the updates from upstream, I can do a
git fetch upstream
git rebase upstream master
to put the changes back to the master branch. When I do a
it will get the code from origin and merge with the current master branch.
(2) When I need to see the content of a previous commit, or revert back to a previous commit, I can do
git checkout xxxxxxxx -b temp
so that i see the previous checked in file in a different branch. Branch is a lot more lightweight in git than in svn.
I can see the file, and whenever I need to get back to the current latest commit, I do a git rebase master.
NOTE: when I do
git checkout xxxx
without specifying a branch, I will be detached from current head and NO LONGER in master branch. As a result, to change anything, we need to checkout the latest branch to reattach to the head of master.