Categories
Git How to Reference

Notes on a Successful Git Branching Model

This refers to the explanation on the web site A Successful Git Branching Model. It was only after reading this article that Git really started to make sense to me. It’s an application of Git, and it seems that Git only makes sense within this context.

  • In this branching model, there are only two branches that live forever.
    • master
    • develop
  • origin/master
    • Where the source code of HEAD always reflects a production-ready state.
  • origin/develop
    • Where the source code of HEAD always reflects a state with the latest delivered development changes for the next release.
    • This branch is also known as the Integration branch.
    • This is where automatic nightly builds are built from.
  • When the source code in develop reaches a stable point and is ready to be released, all of the changes are merged back into master, and then tagged with a release number.
    • By definition, each time changes are merged into master, it’s a new production release.
Categories
Git How to

How can you see the Differences in a File, Between Two Commits?

In Eclipse, right-click the file in Git repository explorer (in the working tree), and then select “Show in > History”. Then, select the two commits in the History pane (hold Ctrl when selecting commit items), and then right-click and select “Compare with each other.

Categories
Git How to

How to Remove Content From the Doc Build

I documented a new feature a month ago, and it’s now live. But now 3rdParty wants me to pull it – because the commercial launch has been delayed.

Since you use a Git branching model to separate your work-in-progress from your published work, and then once you’ve completed the new work, you then merge it into the published doc set, you should be able to solve this issue using Git.

You can remove the content by reversing the commit that represents it. When it’s time to put the content back, you do it by reverting the revert commit. You might think it makes sense to merge the content back in, as you originally did, but Git has captured that “action” as a commit object already (as a dimension, the concept of time takes on properties and behaviors in Git world!).

Here’s my research source: http://git-scm.com/blog/2010/03/02/undoing-merges.html

Notes

In Eclipse > Git Reflog (Java (Writing) perspective).

Looking at the entries in the Reflog Message column, you can easily see where new content was merged into your local main line branch. They’re the “Merge Commits” – the ones with the “merge” icon.

Can you filter-out all of the other commit types? Yes! Simpy type “merge” into the Filter field, and press Enter.

Categories
Git How to

How to Find Out Which Files are Tracked

git ls-files
Categories
Git How to

How to Undo a Commit

git reset HEAD~1
Categories
Git How to

How to Recover a File that was Deleted by a Commit

I’m still not sure how this happened. It could have resulted from switching back and forth between the MobileUserDocs branch and the 2WaySMS branch. You altered your .gitignore to have it ignore

  1. Find the commit that deleted the file.
git rev-list -n 1 HEAD -- <file_path/>

E.g.,

git rev-list -n 1 HEAD -- doc/user/v1/source/mobile-content/topics/procedures.dita
  1. Checkout the file.
git checkout a39f1d72964dfc6240a7c1d9678a4add9b8bdb7d^ -- doc/user/v1/source/mobile-content/topics/procedures.dita

Or in one command

If $file is the file in question.

git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"

Note: You must include the quotes.

E.g.,

File Name: “doc/user/v1/source/mobile-content/topics/concepts.dita”

git checkout $(git rev-list -n 1 HEAD -- "doc/user/v1/source/mobile-content/topics/concepts.dita")^ -- "doc/user/v1/source/mobile-content/topics/concepts.dita"
Categories
Git How to

How to Create a Copy of One of the Remote Branches Locally

Just check it out, using its local name.

E.g.,

git checkout release/current
Categories
Git How to

How to Create a New Branch for the Mobile End User Docs

1. Always use the local feature/api_doc as the starting point

git checkout feature/api_doc

2. Update your local repository

git fetch origin

3. Set the command options

When creating a new branch, set up configuration to mark the start-point branch as “upstream” from the new branch.

--track

Create the branch’s reflog. This activates recording of all changes made to the branch ref, enabling use of date based sha1 expressions such as “<branchname>@{yesterday}”.

-l
The name of the new branch
"MobileUserDocs"

Issue the command

git branch –track -l MobileUserDocs

4. Checkout the new branch

And start working on the AuthID End User documentation.

checkout MobileUserDocs

5. Update your .gitignore file to exclude oXygen’s temp files

doc/user/v1/source/mobile-content/temp

6. Add the new content files to the local repo

Use Stage Changed to get all of the new source files, as well as the 3rdParty.css fileds, the tsmobile.ditamap file, the .project file, and the .gitignore file.

E.g., commit message
First draft of End User documentation.
Categories
Git How to

How to Create a New Branch, Both Locally, and in Origin

  1. git clone git@git.c11.3rdParty.com:mobile_assets.git.
  2. git fetch –all.
  3. git checkout develop.
  4. git checkout -b feature/doc_update.
  5. git push origin feature/doc_update.
Categories
Git How to

How to Pickup Bits from Another Branch

git merge origin/develop