<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://kb.owrench.com/index.php?action=history&amp;feed=atom&amp;title=Everyday_GIT</id>
	<title>Everyday GIT - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://kb.owrench.com/index.php?action=history&amp;feed=atom&amp;title=Everyday_GIT"/>
	<link rel="alternate" type="text/html" href="http://kb.owrench.com/index.php?title=Everyday_GIT&amp;action=history"/>
	<updated>2026-05-04T04:27:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://kb.owrench.com/index.php?title=Everyday_GIT&amp;diff=96&amp;oldid=prev</id>
		<title>imported&gt;Kishor at 09:04, 16 June 2017</title>
		<link rel="alternate" type="text/html" href="http://kb.owrench.com/index.php?title=Everyday_GIT&amp;diff=96&amp;oldid=prev"/>
		<updated>2017-06-16T09:04:36Z</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;Basic commands used:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    git-init(1) to create a new repository.&lt;br /&gt;
&lt;br /&gt;
    git-log(1) to see what happened.&lt;br /&gt;
&lt;br /&gt;
    git-checkout(1) and git-branch(1) to switch branches.&lt;br /&gt;
&lt;br /&gt;
    git-add(1) to manage the index file.&lt;br /&gt;
&lt;br /&gt;
    git-diff(1) and git-status(1) to see what you are in the middle of doing.&lt;br /&gt;
&lt;br /&gt;
    git-commit(1) to advance the current branch.&lt;br /&gt;
&lt;br /&gt;
    git-reset(1) and git-checkout(1) (with pathname parameters) to undo changes.&lt;br /&gt;
&lt;br /&gt;
    git-merge(1) to merge between local branches.&lt;br /&gt;
&lt;br /&gt;
    git-rebase(1) to maintain topic branches.&lt;br /&gt;
&lt;br /&gt;
    git-tag(1) to mark a known point.&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&lt;br /&gt;
Use a tarball as a starting point for a new repository.&lt;br /&gt;
&lt;br /&gt;
    $ tar zxf frotz.tar.gz&lt;br /&gt;
    $ cd frotz&lt;br /&gt;
    $ git init&lt;br /&gt;
    $ git add . &amp;lt;1&amp;gt;&lt;br /&gt;
    $ git commit -m &amp;quot;import of frotz source tree.&amp;quot;&lt;br /&gt;
    $ git tag v2.43 &amp;lt;2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        add everything under the current directory.&lt;br /&gt;
&lt;br /&gt;
        make a lightweight, unannotated tag.&lt;br /&gt;
&lt;br /&gt;
Create a topic branch and develop.&lt;br /&gt;
&lt;br /&gt;
    $ git checkout -b alsa-audio &amp;lt;1&amp;gt;&lt;br /&gt;
    $ edit/compile/test&lt;br /&gt;
    $ git checkout -- curses/ux_audio_oss.c &amp;lt;2&amp;gt;&lt;br /&gt;
    $ git add curses/ux_audio_alsa.c &amp;lt;3&amp;gt;&lt;br /&gt;
    $ edit/compile/test&lt;br /&gt;
    $ git diff HEAD &amp;lt;4&amp;gt;&lt;br /&gt;
    $ git commit -a -s &amp;lt;5&amp;gt;&lt;br /&gt;
    $ edit/compile/test&lt;br /&gt;
    $ git diff HEAD^ &amp;lt;6&amp;gt;&lt;br /&gt;
    $ git commit -a --amend &amp;lt;7&amp;gt;&lt;br /&gt;
    $ git checkout master &amp;lt;8&amp;gt;&lt;br /&gt;
    $ git merge alsa-audio &amp;lt;9&amp;gt;&lt;br /&gt;
    $ git log --since='3 days ago' &amp;lt;10&amp;gt;&lt;br /&gt;
    $ git log v2.43.. curses/ &amp;lt;11&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        create a new topic branch.&lt;br /&gt;
&lt;br /&gt;
        revert your botched changes in curses/ux_audio_oss.c.&lt;br /&gt;
&lt;br /&gt;
        you need to tell Git if you added a new file; removal and modification will be caught if you do git commit -a later.&lt;br /&gt;
&lt;br /&gt;
        to see what changes you are committing.&lt;br /&gt;
&lt;br /&gt;
        commit everything, as you have tested, with your sign-off.&lt;br /&gt;
&lt;br /&gt;
        look at all your changes including the previous commit.&lt;br /&gt;
&lt;br /&gt;
        amend the previous commit, adding all your new changes, using your original message.&lt;br /&gt;
&lt;br /&gt;
        switch to the master branch.&lt;br /&gt;
&lt;br /&gt;
        merge a topic branch into your master branch.&lt;br /&gt;
&lt;br /&gt;
        review commit logs; other forms to limit output can be combined and include -10 (to show up to 10 commits), --until=2005-12-10, etc.&lt;br /&gt;
&lt;br /&gt;
        view only the changes that touch what’s in curses/ directory, since v2.43 tag.&lt;br /&gt;
&lt;br /&gt;
Individual Developer (Participant)&lt;br /&gt;
&lt;br /&gt;
A developer working as a participant in a group project needs to learn how to communicate with others, and uses these commands in addition to the ones needed by a standalone developer.&lt;br /&gt;
&lt;br /&gt;
    git-clone(1) from the upstream to prime your local repository.&lt;br /&gt;
&lt;br /&gt;
    git-pull(1) and git-fetch(1) from &amp;quot;origin&amp;quot; to keep up-to-date with the upstream.&lt;br /&gt;
&lt;br /&gt;
    git-push(1) to shared repository, if you adopt CVS style shared repository workflow.&lt;br /&gt;
&lt;br /&gt;
    git-format-patch(1) to prepare e-mail submission, if you adopt Linux kernel-style public forum workflow.&lt;br /&gt;
&lt;br /&gt;
    git-send-email(1) to send your e-mail submission without corruption by your MUA.&lt;br /&gt;
&lt;br /&gt;
    git-request-pull(1) to create a summary of changes for your upstream to pull.&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&lt;br /&gt;
Clone the upstream and work on it. Feed changes to upstream.&lt;br /&gt;
&lt;br /&gt;
    $ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6&lt;br /&gt;
    $ cd my2.6&lt;br /&gt;
    $ git checkout -b mine master &amp;lt;1&amp;gt;&lt;br /&gt;
    $ edit/compile/test; git commit -a -s &amp;lt;2&amp;gt;&lt;br /&gt;
    $ git format-patch master &amp;lt;3&amp;gt;&lt;br /&gt;
    $ git send-email --to=&amp;quot;person &amp;lt;email@example.com&amp;gt;&amp;quot; 00*.patch &amp;lt;4&amp;gt;&lt;br /&gt;
    $ git checkout master &amp;lt;5&amp;gt;&lt;br /&gt;
    $ git pull &amp;lt;6&amp;gt;&lt;br /&gt;
    $ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 &amp;lt;7&amp;gt;&lt;br /&gt;
    $ git ls-remote --heads http://git.kernel.org/.../jgarzik/libata-dev.git &amp;lt;8&amp;gt;&lt;br /&gt;
    $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL &amp;lt;9&amp;gt;&lt;br /&gt;
    $ git reset --hard ORIG_HEAD &amp;lt;10&amp;gt;&lt;br /&gt;
    $ git gc &amp;lt;11&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        checkout a new branch mine from master.&lt;br /&gt;
&lt;br /&gt;
        repeat as needed.&lt;br /&gt;
&lt;br /&gt;
        extract patches from your branch, relative to master,&lt;br /&gt;
&lt;br /&gt;
        and email them.&lt;br /&gt;
&lt;br /&gt;
        return to master, ready to see what’s new&lt;br /&gt;
&lt;br /&gt;
        git pull fetches from origin by default and merges into the current branch.&lt;br /&gt;
&lt;br /&gt;
        immediately after pulling, look at the changes done upstream since last time we checked, only in the area we are interested in.&lt;br /&gt;
&lt;br /&gt;
        check the branch names in an external repository (if not known).&lt;br /&gt;
&lt;br /&gt;
        fetch from a specific branch ALL from a specific repository and merge it.&lt;br /&gt;
&lt;br /&gt;
        revert the pull.&lt;br /&gt;
&lt;br /&gt;
        garbage collect leftover objects from reverted pull.&lt;br /&gt;
&lt;br /&gt;
Push into another repository.&lt;br /&gt;
&lt;br /&gt;
    satellite$ git clone mothership:frotz frotz &amp;lt;1&amp;gt;&lt;br /&gt;
    satellite$ cd frotz&lt;br /&gt;
    satellite$ git config --get-regexp '^(remote|branch)\.' &amp;lt;2&amp;gt;&lt;br /&gt;
    remote.origin.url mothership:frotz&lt;br /&gt;
    remote.origin.fetch refs/heads/*:refs/remotes/origin/*&lt;br /&gt;
    branch.master.remote origin&lt;br /&gt;
    branch.master.merge refs/heads/master&lt;br /&gt;
    satellite$ git config remote.origin.push \&lt;br /&gt;
               +refs/heads/*:refs/remotes/satellite/* &amp;lt;3&amp;gt;&lt;br /&gt;
    satellite$ edit/compile/test/commit&lt;br /&gt;
    satellite$ git push origin &amp;lt;4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    mothership$ cd frotz&lt;br /&gt;
    mothership$ git checkout master&lt;br /&gt;
    mothership$ git merge satellite/master &amp;lt;5&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        mothership machine has a frotz repository under your home directory; clone from it to start a repository on the satellite machine.&lt;br /&gt;
&lt;br /&gt;
        clone sets these configuration variables by default. It arranges git pull to fetch and store the branches of mothership machine to local remotes/origin/* remote-tracking branches.&lt;br /&gt;
&lt;br /&gt;
        arrange git push to push all local branches to their corresponding branch of the mothership machine.&lt;br /&gt;
&lt;br /&gt;
        push will stash all our work away on remotes/satellite/* remote-tracking branches on the mothership machine. You could use this as a back-up method. Likewise, you can pretend that mothership &amp;quot;fetched&amp;quot; from you (useful when access is one sided).&lt;br /&gt;
&lt;br /&gt;
        on mothership machine, merge the work done on the satellite machine into the master branch.&lt;br /&gt;
&lt;br /&gt;
Branch off of a specific tag.&lt;br /&gt;
&lt;br /&gt;
    $ git checkout -b private2.6.14 v2.6.14 &amp;lt;1&amp;gt;&lt;br /&gt;
    $ edit/compile/test; git commit -a&lt;br /&gt;
    $ git checkout master&lt;br /&gt;
    $ git cherry-pick v2.6.14..private2.6.14 &amp;lt;2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        create a private branch based on a well known (but somewhat behind) tag.&lt;br /&gt;
&lt;br /&gt;
        forward port all changes in private2.6.14 branch to master branch without a formal &amp;quot;merging&amp;quot;. Or longhand&lt;br /&gt;
        git format-patch -k -m --stdout v2.6.14..private2.6.14 | git am -3 -k&lt;br /&gt;
&lt;br /&gt;
An alternate participant submission mechanism is using the git request-pull or pull-request mechanisms (e.g as used on GitHub (www.github.com) to notify your upstream of your contribution.&lt;br /&gt;
Integrator&lt;br /&gt;
&lt;br /&gt;
A fairly central person acting as the integrator in a group project receives changes made by others, reviews and integrates them and publishes the result for others to use, using these commands in addition to the ones needed by participants.&lt;br /&gt;
&lt;br /&gt;
This section can also be used by those who respond to git request-pull or pull-request on GitHub (www.github.com) to integrate the work of others into their history. An sub-area lieutenant for a repository will act both as a participant and as an integrator.&lt;br /&gt;
&lt;br /&gt;
    git-am(1) to apply patches e-mailed in from your contributors.&lt;br /&gt;
&lt;br /&gt;
    git-pull(1) to merge from your trusted lieutenants.&lt;br /&gt;
&lt;br /&gt;
    git-format-patch(1) to prepare and send suggested alternative to contributors.&lt;br /&gt;
&lt;br /&gt;
    git-revert(1) to undo botched commits.&lt;br /&gt;
&lt;br /&gt;
    git-push(1) to publish the bleeding edge.&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&lt;br /&gt;
A typical integrator’s Git day.&lt;br /&gt;
&lt;br /&gt;
    $ git status &amp;lt;1&amp;gt;&lt;br /&gt;
    $ git branch --no-merged master &amp;lt;2&amp;gt;&lt;br /&gt;
    $ mailx &amp;lt;3&amp;gt;&lt;br /&gt;
    &amp;amp; s 2 3 4 5 ./+to-apply&lt;br /&gt;
    &amp;amp; s 7 8 ./+hold-linus&lt;br /&gt;
    &amp;amp; q&lt;br /&gt;
    $ git checkout -b topic/one master&lt;br /&gt;
    $ git am -3 -i -s ./+to-apply &amp;lt;4&amp;gt;&lt;br /&gt;
    $ compile/test&lt;br /&gt;
    $ git checkout -b hold/linus &amp;amp;&amp;amp; git am -3 -i -s ./+hold-linus &amp;lt;5&amp;gt;&lt;br /&gt;
    $ git checkout topic/one &amp;amp;&amp;amp; git rebase master &amp;lt;6&amp;gt;&lt;br /&gt;
    $ git checkout pu &amp;amp;&amp;amp; git reset --hard next &amp;lt;7&amp;gt;&lt;br /&gt;
    $ git merge topic/one topic/two &amp;amp;&amp;amp; git merge hold/linus &amp;lt;8&amp;gt;&lt;br /&gt;
    $ git checkout maint&lt;br /&gt;
    $ git cherry-pick master~4 &amp;lt;9&amp;gt;&lt;br /&gt;
    $ compile/test&lt;br /&gt;
    $ git tag -s -m &amp;quot;GIT 0.99.9x&amp;quot; v0.99.9x &amp;lt;10&amp;gt;&lt;br /&gt;
    $ git fetch ko &amp;amp;&amp;amp; for branch in master maint next pu &amp;lt;11&amp;gt;&lt;br /&gt;
        do&lt;br /&gt;
            git show-branch ko/$branch $branch &amp;lt;12&amp;gt;&lt;br /&gt;
        done&lt;br /&gt;
    $ git push --follow-tags ko &amp;lt;13&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        see what you were in the middle of doing, if anything.&lt;br /&gt;
&lt;br /&gt;
        see which branches haven’t been merged into master yet. Likewise for any other integration branches e.g. maint, next and pu (potential updates).&lt;br /&gt;
&lt;br /&gt;
        read mails, save ones that are applicable, and save others that are not quite ready (other mail readers are available).&lt;br /&gt;
&lt;br /&gt;
        apply them, interactively, with your sign-offs.&lt;br /&gt;
&lt;br /&gt;
        create topic branch as needed and apply, again with sign-offs.&lt;br /&gt;
&lt;br /&gt;
        rebase internal topic branch that has not been merged to the master or exposed as a part of a stable branch.&lt;br /&gt;
&lt;br /&gt;
        restart pu every time from the next.&lt;br /&gt;
&lt;br /&gt;
        and bundle topic branches still cooking.&lt;br /&gt;
&lt;br /&gt;
        backport a critical fix.&lt;br /&gt;
&lt;br /&gt;
        create a signed tag.&lt;br /&gt;
&lt;br /&gt;
        make sure master was not accidentally rewound beyond that already pushed out.&lt;br /&gt;
&lt;br /&gt;
        In the output from git show-branch, master should have everything ko/master has, and next should have everything ko/next has, etc.&lt;br /&gt;
&lt;br /&gt;
        push out the bleeding edge, together with new tags that point into the pushed history.&lt;br /&gt;
&lt;br /&gt;
In this example, the ko shorthand points at the Git maintainer’s repository at kernel.org, and looks like this:&lt;br /&gt;
&lt;br /&gt;
(in .git/config)&lt;br /&gt;
[remote &amp;quot;ko&amp;quot;]&lt;br /&gt;
        url = kernel.org:/pub/scm/git/git.git&lt;br /&gt;
        fetch = refs/heads/*:refs/remotes/ko/*&lt;br /&gt;
        push = refs/heads/master&lt;br /&gt;
        push = refs/heads/next&lt;br /&gt;
        push = +refs/heads/pu&lt;br /&gt;
        push = refs/heads/maint&lt;br /&gt;
&lt;br /&gt;
Repository Administration&lt;br /&gt;
&lt;br /&gt;
A repository administrator uses the following tools to set up and maintain access to the repository by developers.&lt;br /&gt;
&lt;br /&gt;
    git-daemon(1) to allow anonymous download from repository.&lt;br /&gt;
&lt;br /&gt;
    git-shell(1) can be used as a restricted login shell for shared central repository users.&lt;br /&gt;
&lt;br /&gt;
    git-http-backend(1) provides a server side implementation of Git-over-HTTP (&amp;quot;Smart http&amp;quot;) allowing both fetch and push services.&lt;br /&gt;
&lt;br /&gt;
    gitweb(1) provides a web front-end to Git repositories, which can be set-up using the git-instaweb(1) script.&lt;br /&gt;
&lt;br /&gt;
update hook howto has a good example of managing a shared central repository.&lt;br /&gt;
&lt;br /&gt;
In addition there are a number of other widely deployed hosting, browsing and reviewing solutions such as:&lt;br /&gt;
&lt;br /&gt;
    gitolite, gerrit code review, cgit and others.&lt;br /&gt;
&lt;br /&gt;
Examples&lt;br /&gt;
&lt;br /&gt;
We assume the following in /etc/services&lt;br /&gt;
&lt;br /&gt;
    $ grep 9418 /etc/services&lt;br /&gt;
    git             9418/tcp                # Git Version Control System&lt;br /&gt;
&lt;br /&gt;
Run git-daemon to serve /pub/scm from inetd.&lt;br /&gt;
&lt;br /&gt;
    $ grep git /etc/inetd.conf&lt;br /&gt;
    git     stream  tcp     nowait  nobody \&lt;br /&gt;
      /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm&lt;br /&gt;
&lt;br /&gt;
    The actual configuration line should be on one line.&lt;br /&gt;
Run git-daemon to serve /pub/scm from xinetd.&lt;br /&gt;
&lt;br /&gt;
    $ cat /etc/xinetd.d/git-daemon&lt;br /&gt;
    # default: off&lt;br /&gt;
    # description: The Git server offers access to Git repositories&lt;br /&gt;
    service git&lt;br /&gt;
    {&lt;br /&gt;
            disable = no&lt;br /&gt;
            type            = UNLISTED&lt;br /&gt;
            port            = 9418&lt;br /&gt;
            socket_type     = stream&lt;br /&gt;
            wait            = no&lt;br /&gt;
            user            = nobody&lt;br /&gt;
            server          = /usr/bin/git-daemon&lt;br /&gt;
            server_args     = --inetd --export-all --base-path=/pub/scm&lt;br /&gt;
            log_on_failure  += USERID&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Check your xinetd(8) documentation and setup, this is from a Fedora system. Others might be different.&lt;br /&gt;
Give push/pull only access to developers using git-over-ssh.&lt;br /&gt;
&lt;br /&gt;
    e.g. those using: $ git push/pull ssh://host.xz/pub/scm/project&lt;br /&gt;
&lt;br /&gt;
    $ grep git /etc/passwd &amp;lt;1&amp;gt;&lt;br /&gt;
    alice:x:1000:1000::/home/alice:/usr/bin/git-shell&lt;br /&gt;
    bob:x:1001:1001::/home/bob:/usr/bin/git-shell&lt;br /&gt;
    cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell&lt;br /&gt;
    david:x:1003:1003::/home/david:/usr/bin/git-shell&lt;br /&gt;
    $ grep git /etc/shells &amp;lt;2&amp;gt;&lt;br /&gt;
    /usr/bin/git-shell&lt;br /&gt;
&lt;br /&gt;
        log-in shell is set to /usr/bin/git-shell, which does not allow anything but git push and git pull. The users require ssh access to the machine.&lt;br /&gt;
&lt;br /&gt;
        in many distributions /etc/shells needs to list what is used as the login shell.&lt;br /&gt;
&lt;br /&gt;
CVS-style shared repository.&lt;br /&gt;
&lt;br /&gt;
    $ grep git /etc/group &amp;lt;1&amp;gt;&lt;br /&gt;
    git:x:9418:alice,bob,cindy,david&lt;br /&gt;
    $ cd /home/devo.git&lt;br /&gt;
    $ ls -l &amp;lt;2&amp;gt;&lt;br /&gt;
      lrwxrwxrwx   1 david git    17 Dec  4 22:40 HEAD -&amp;gt; refs/heads/master&lt;br /&gt;
      drwxrwsr-x   2 david git  4096 Dec  4 22:40 branches&lt;br /&gt;
      -rw-rw-r--   1 david git    84 Dec  4 22:40 config&lt;br /&gt;
      -rw-rw-r--   1 david git    58 Dec  4 22:40 description&lt;br /&gt;
      drwxrwsr-x   2 david git  4096 Dec  4 22:40 hooks&lt;br /&gt;
      -rw-rw-r--   1 david git 37504 Dec  4 22:40 index&lt;br /&gt;
      drwxrwsr-x   2 david git  4096 Dec  4 22:40 info&lt;br /&gt;
      drwxrwsr-x   4 david git  4096 Dec  4 22:40 objects&lt;br /&gt;
      drwxrwsr-x   4 david git  4096 Nov  7 14:58 refs&lt;br /&gt;
      drwxrwsr-x   2 david git  4096 Dec  4 22:40 remotes&lt;br /&gt;
    $ ls -l hooks/update &amp;lt;3&amp;gt;&lt;br /&gt;
      -r-xr-xr-x   1 david git  3536 Dec  4 22:40 update&lt;br /&gt;
    $ cat info/allowed-users &amp;lt;4&amp;gt;&lt;br /&gt;
    refs/heads/master       alice\|cindy&lt;br /&gt;
    refs/heads/doc-update   bob&lt;br /&gt;
    refs/tags/v[0-9]*       david&lt;br /&gt;
&lt;br /&gt;
[[category:it-support]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Kishor</name></author>
		
	</entry>
</feed>