Continuing on with our small series of posts about Git and some of the commands we use at PhraseApp when working with the powerful SCM. We started by explaining the basic concept of Git briefly and diving into advanced usage of Git rebase.
Trick #2: Double Dash To Scope On A Folder
This command shows you the commits that have happened in Revision
OTHERREVISION but not yet in
git log PASTREVISION..OTHERREVISION
If you add a path prefix after the double dash (
--) it shows you commits that affected files with that prefix only:
git log PASTREVISION..OTHERREVISION -- app/folder
The same goes for multiple other commands such as
git diff, which can show you what changes a specific branch or tag introduces on files in a specific folder (or with a certain prefix):
git diff origin/master..branch -- app/models
Trick #3: Get The Current Revision Hash For Scripting
git rev-parse HEAD
Returns the hash of the presented tag.
HEAD is the tag for latest revision on the currently active branch. You can also specify the hash
origin/master to get the (last locally fetched) revision of the remote master branch. A tilde after any tag indicates a step backward, so
HEAD~2 means two commits before
HEAD on the current branch.
Be sure to subscribe and receive all updates from the PhraseApp blog straight to your inbox. You’ll receive localization best practices, about cultural aspects of breaking into new markets, guides and tutorials for optimizing software translation and other industry insights and information. Don’t miss out!