<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Git_-_Workflow_Patterns</id>
	<title>Git - Workflow Patterns - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Git_-_Workflow_Patterns"/>
	<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Git_-_Workflow_Patterns&amp;action=history"/>
	<updated>2026-05-13T06:43:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://training-course-material.com/index.php?title=Git_-_Workflow_Patterns&amp;diff=23916&amp;oldid=prev</id>
		<title>Cesar Chew at 16:34, 24 November 2014</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Git_-_Workflow_Patterns&amp;diff=23916&amp;oldid=prev"/>
		<updated>2014-11-24T16:34:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Git|090]]&lt;br /&gt;
&lt;br /&gt;
== Collaboration models ==&lt;br /&gt;
* Push to central (bare) repo&lt;br /&gt;
* Pull Only&lt;br /&gt;
** each user has public repo&lt;br /&gt;
** patches send via emails&lt;br /&gt;
* Hybrid&lt;br /&gt;
* Public repos&lt;br /&gt;
* Emails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Central Repo (Push) ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 mkdir ~/repo&lt;br /&gt;
 cd ~/repo&lt;br /&gt;
 git init&lt;br /&gt;
 echo new_file &amp;gt; new_file&lt;br /&gt;
 git add .&lt;br /&gt;
 git commit -m &amp;quot;first commit&amp;quot;&lt;br /&gt;
 git status&lt;br /&gt;
 git clone ~/repo ~/central.git --bare&lt;br /&gt;
 git clone central.git kate&lt;br /&gt;
 git clone central.git harry&lt;br /&gt;
 cd kate; &lt;br /&gt;
 echo change by kate &amp;gt;&amp;gt; afile.txt&lt;br /&gt;
 git add afile.txt&lt;br /&gt;
 git commit -a -m &amp;quot;change by kate&amp;quot;&lt;br /&gt;
 git push&lt;br /&gt;
&lt;br /&gt;
 cd ../harry; touch filebyharry.txt&lt;br /&gt;
 git add filebyharry.txt; &lt;br /&gt;
 git commit  -m &amp;quot;change by harry&amp;quot;&lt;br /&gt;
 git pull&lt;br /&gt;
 git push&lt;br /&gt;
&lt;br /&gt;
 cd ../kate&lt;br /&gt;
 git pull&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Pushing Tags ==&lt;br /&gt;
 git push --tags&lt;br /&gt;
&lt;br /&gt;
=== Pushing branches ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
  cd /g/kate&lt;br /&gt;
  git checkout -b katebranch&lt;br /&gt;
  echo asdf &amp;gt; katebranch.txt&lt;br /&gt;
  git add katebranch.txt&lt;br /&gt;
  git commit -m &amp;quot;Katebranch changes&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
  git branch -a&lt;br /&gt;
  git push origin katebranch&lt;br /&gt;
  git branch -a &lt;br /&gt;
&lt;br /&gt;
  cd /g/harry&lt;br /&gt;
  git pull&lt;br /&gt;
  git checkout origin/katebranch -b katebranch&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
[[File:Git-push.png|360px]]&lt;br /&gt;
&lt;br /&gt;
== Central Repo ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
* Simple structure&lt;br /&gt;
* No need for release manager (in theory)&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
* May lead to conflicts&lt;br /&gt;
* Need for permission system&lt;br /&gt;
* Doesn&amp;#039;t scale well&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pull Only ==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;JinTao&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;Barak&amp;#039;&amp;#039;&amp;#039; are developers&lt;br /&gt;
* They are not getting well together (they tend not to trust each other)&lt;br /&gt;
* Each of them thinks they are better programmer than the other&lt;br /&gt;
* Central repository didn&amp;#039;t work for them as they conflict a lot, but they are interested in each other works&lt;br /&gt;
* The production repository is managed by Mr. &amp;#039;&amp;#039;&amp;#039;UN&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Git-pullonly.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Pull Only (Integration Manager Workflow)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Git-pullonly-wf.png|350px]]&lt;br /&gt;
&lt;br /&gt;
== Public Repos ==&lt;br /&gt;
[[File:Git-public-repos.png|350px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Email ==&lt;br /&gt;
 git checkout -b harryprivatebranch &lt;br /&gt;
 echo harry changes1 &amp;gt;&amp;gt; afile.txt &lt;br /&gt;
 echo harry changes2 &amp;gt;&amp;gt; afile.txt &lt;br /&gt;
 git commit -a&lt;br /&gt;
 git format-patch master&lt;br /&gt;
 cat 0001-harry-changes-commit-message.patch &lt;br /&gt;
 cp 0001-harry-changes-commit-message.patch  /rcs/kate/&lt;br /&gt;
 kate@kate$ git apply 0001-harry-changes-commit-message.patch&lt;br /&gt;
 git diff&lt;br /&gt;
 git commit -a&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Email from mbox files ==&lt;br /&gt;
 $ git am patches.mbox&lt;br /&gt;
* apply all patches from the mail&lt;br /&gt;
* can be used with “-3” option to perform the merge automatically&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Git]]&lt;br /&gt;
&lt;br /&gt;
== Distributed Workflows ==&lt;br /&gt;
=== Centralized Workflow ===&lt;br /&gt;
[[File:Git-central-wf.png|300px]]&lt;br /&gt;
&lt;br /&gt;
* A single collaboration model—the centralized workflow&lt;br /&gt;
* One central hub, or repository, can accept code, and everyone synchronizes their work to it. &lt;br /&gt;
* A number of developers are nodes — consumers of that hub — and synchronize to that one place &lt;br /&gt;
* If two developers clone from the hub and both make changes, the first developer to push their changes back up can do so with no problems. The second developer must merge in the first one’s work before pushing changes up, so as not to overwrite the first developer’s changes. &lt;br /&gt;
* This concept is true in Git as it is in Subversion (or any CVCS), and this model works perfectly in Git.&lt;br /&gt;
* If you have a small team or are already comfortable with a centralized workflow in your company or team, you can easily continue using that workflow with Git. &lt;br /&gt;
* Simply set up a single repository, and give everyone on your team push access; &lt;br /&gt;
* Git won’t let users overwrite each other. &lt;br /&gt;
* If one developer clones, makes changes, and then tries to push their changes while another developer has pushed in the meantime, the server will reject that developer’s changes. They will be told that they’re trying to push non-fast-forward changes and that they won’t be able to do so until they fetch and merge.&lt;br /&gt;
* attractive to a lot of people as it’s a paradigm that many are familiar and comfortable with.&lt;br /&gt;
&lt;br /&gt;
=== Integration-Manager Workflow ===&lt;br /&gt;
* Because Git allows you to have multiple remote repositories, it’s possible to have a workflow where each developer has write access to their own public repository and read access to everyone else’s. &lt;br /&gt;
* This scenario often includes a canonical repository that represents the &amp;quot;official&amp;quot; project. To contribute to that project, you create your own public clone of the project and push your changes to it. &lt;br /&gt;
* Then, you can send a request to the maintainer of the main project to pull in your changes. &lt;br /&gt;
* They can add your repository as a remote, test your changes locally, merge them into their branch, and push back to their repository. &lt;br /&gt;
* a very common workflow with sites like GitHub, where it’s easy to fork a project and push your changes into your fork for everyone to see. &lt;br /&gt;
* you can continue to work, and the maintainer of the main repository can pull in your changes at any&lt;br /&gt;
time. Contributors don’t have to wait for the project to incorporate their changes — each party can work at their own pace.&lt;br /&gt;
&lt;br /&gt;
[[File:Git-inte-man-wf.png|400px]]&lt;br /&gt;
# The project maintainer pushes to their public repository.&lt;br /&gt;
# A contributor clones that repository and makes changes.&lt;br /&gt;
# The contributor pushes to their own public copy.&lt;br /&gt;
# The contributor sends the maintainer an e-mail asking them to pull changes.&lt;br /&gt;
# The maintainer adds the contributor’s repo as a remote and merges locally.&lt;br /&gt;
# The maintainer pushes merged changes to the main repository.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Dictator and Lieutenants Workflow ===&lt;br /&gt;
* a variant of a multiple-repository workflow. &lt;br /&gt;
* used by huge projects with hundreds of collaborators; one famous example is the Linux kernel.&lt;br /&gt;
* Various integration managers are in charge of certain parts of the repository; they’re called lieutenants. &lt;br /&gt;
* All the lieutenants have one integration manager known as the benevolent dictator. &lt;br /&gt;
* The benevolent dictator’s repository serves as the reference repository from which all the collaborators need to pull. &lt;br /&gt;
* not very common but can be useful in very big projects or in highly hierarchical environments, because as it allows the project leader (the dictator) to delegate much of the work and collect large subsets of code at multiple points before integrating them.&lt;br /&gt;
&lt;br /&gt;
[[File:Git-dic-lie-wf.png|300px]]&lt;br /&gt;
# Regular developers work on their topic branch and rebase their work on top of master. The master branch is that of the dictator.&lt;br /&gt;
# Lieutenants merge the developers’ topic branches into their master branch.&lt;br /&gt;
# The dictator merges the lieutenants’ master branches into the dictator’s master branch.&lt;br /&gt;
# The dictator pushes their master to the reference repository so the other developers can rebase on it.&lt;br /&gt;
&lt;br /&gt;
== Contributing to a project ==&lt;br /&gt;
=== Private Small Team ===&lt;br /&gt;
[[File:Git-private-small-team.png|250px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Private Managed Team ===&lt;br /&gt;
[[File:Git-private-managed-team.png|380px]]&lt;br /&gt;
&lt;br /&gt;
=== Public Small Project ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Public Large Project ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Central vs Hybrid ==&lt;br /&gt;
[[File:Git-cen-hyb.png|350px]]&lt;br /&gt;
&lt;br /&gt;
== Generating a Build Number ==&lt;br /&gt;
 git describe master --long&lt;br /&gt;
&lt;br /&gt;
 #Create a package&lt;br /&gt;
 git archive master --prefix=&amp;#039;project/&amp;#039; | gzip &amp;gt; `git describe master`.tar.gz&lt;br /&gt;
&lt;br /&gt;
 # Deploy files directly&lt;br /&gt;
 git archive master --prefix=&amp;#039;project/&amp;#039; | tar x&lt;br /&gt;
&lt;br /&gt;
== Short logs ==&lt;br /&gt;
&lt;br /&gt;
 git shortlog --no-merges master --not v1.0.1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 git shortlog --no-merges v1.1..v1.4&lt;/div&gt;</summary>
		<author><name>Cesar Chew</name></author>
	</entry>
</feed>