Personal tools
You are here: Home Plone XP Open Source Software Review Git in Advance

Git in Advance

some advance usage for Git.

Powerful Rebase

Follw the steps to remove a commit:

$ git rebase -i HEAD~10
# using editor to remove the whole line for the commit you want to remove.
$ git push origin +master

Some good posts:

Merge Git Repo One into Another

Mainly based on the question how to import git repo into another on stackoverflow.

Here is my steps:

git remote add other /path/to/XXX
git fetch other
git checkout -b ZZZ other/master
mkdir ZZZ
git mv stuff ZZZ/stuff             # as necessary
git commit -m "Moved stuff to ZZZ"
git checkout master
git merge ZZZ                      # should add ZZZ/ to master
git commit
git remote rm other
git branch -d ZZZ                  # to get rid of the extra branch before pushing
git push                           # if you have a remote, that is

Git Archive and Roll Back

Git archive will allow you to create a archive from any commit. This petentially gives us another way to roll back changes.

Here is a sample to create git archive:

$ cd [GIT-REPO-ROOT-FOLDER]
$ cd wp-content/themes/theme-one
$ git archive -o theme-one-[COMMIT ID].zip [COMMIT ID].zip

No path specified tells git to use the current working folder.

Merge Commits in One Folder

based on git read-tree

git show

the command git show could be used to show details about a file:

$ git show master:full/path/to/a/file

Cherry Pick and Merge

The option -x will all you to record the original commit id (RHA1) in the new commit.

The command cherry could be used to compare the changes in two branch.

Document Actions