3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.36.1.153.gf9b95943b6
10 .TH "GITEVERYDAY" "7" "05/20/2022" "Git 2\&.36\&.1\&.153\&.gf9b959" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 giteveryday \- A useful minimum set of commands for Everyday Git
34 Everyday Git With 20 Commands Or So
37 Git users can broadly be grouped into four categories for the purposes of describing here a small set of useful command for everyday Git\&.
47 Individual Developer (Standalone)
48 commands are essential for anybody who makes a commit, even for somebody who works alone\&.
59 If you work with other people, you will need commands listed in the
60 Individual Developer (Participant)
74 role need to learn some more commands in addition to the above\&.
85 Repository Administration
86 commands are for system administrators who are responsible for the care and feeding of Git repositories\&.
88 .SH "INDIVIDUAL DEVELOPER (STANDALONE)"
90 A standalone individual developer does not exchange patches with other people, and works alone in a single repository, using the following commands\&.
101 to create a new repository\&.
113 to see what happened\&.
127 to switch branches\&.
139 to manage the index file\&.
153 to see what you are in the middle of doing\&.
165 to advance the current branch\&.
189 to merge between local branches\&.
201 to maintain topic branches\&.
213 to mark a known point\&.
217 Use a tarball as a starting point for a new repository\&.
224 $ tar zxf frotz\&.tar\&.gz
227 $ git add \&. \fB(1)\fR
228 $ git commit \-m "import of frotz source tree\&."
229 $ git tag v2\&.43 \fB(2)\fR
235 \fB1. \fRadd everything under the current directory\&.
237 \fB2. \fRmake a lightweight, unannotated tag\&.
241 Create a topic branch and develop\&.
248 $ git switch \-c alsa\-audio \fB(1)\fR
250 $ git restore curses/ux_audio_oss\&.c \fB(2)\fR
251 $ git add curses/ux_audio_alsa\&.c \fB(3)\fR
253 $ git diff HEAD \fB(4)\fR
254 $ git commit \-a \-s \fB(5)\fR
256 $ git diff HEAD^ \fB(6)\fR
257 $ git commit \-a \-\-amend \fB(7)\fR
258 $ git switch master \fB(8)\fR
259 $ git merge alsa\-audio \fB(9)\fR
260 $ git log \-\-since=\(aq3 days ago\(aq \fB(10)\fR
261 $ git log v2\&.43\&.\&. curses/ \fB(11)\fR
267 \fB1. \fRcreate a new topic branch\&.
269 \fB2. \fRrevert your botched changes in
270 \fBcurses/ux_audio_oss\&.c\fR\&.
272 \fB3. \fRyou need to tell Git if you added a new file; removal and modification will be caught if you do
276 \fB4. \fRto see what changes you are committing\&.
278 \fB5. \fRcommit everything, as you have tested, with your sign\-off\&.
280 \fB6. \fRlook at all your changes including the previous commit\&.
282 \fB7. \fRamend the previous commit, adding all your new changes, using your original message\&.
284 \fB8. \fRswitch to the master branch\&.
286 \fB9. \fRmerge a topic branch into your master branch\&.
288 \fB10. \fRreview commit logs; other forms to limit output can be combined and include
290 (to show up to 10 commits),
291 \fB\-\-until=2005\-12\-10\fR, etc\&.
293 \fB11. \fRview only the changes that touch what\(cqs in
300 .SH "INDIVIDUAL DEVELOPER (PARTICIPANT)"
302 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\&.
313 from the upstream to prime your local repository\&.
327 from "origin" to keep up\-to\-date with the upstream\&.
339 to shared repository, if you adopt CVS style shared repository workflow\&.
350 \fBgit-format-patch\fR(1)
351 to prepare e\-mail submission, if you adopt Linux kernel\-style public forum workflow\&.
362 \fBgit-send-email\fR(1)
363 to send your e\-mail submission without corruption by your MUA\&.
374 \fBgit-request-pull\fR(1)
375 to create a summary of changes for your upstream to pull\&.
379 Clone the upstream and work on it\&. Feed changes to upstream\&.
386 $ git clone git://git\&.kernel\&.org/pub/scm/\&.\&.\&./torvalds/linux\-2\&.6 my2\&.6
388 $ git switch \-c mine master \fB(1)\fR
389 $ edit/compile/test; git commit \-a \-s \fB(2)\fR
390 $ git format\-patch master \fB(3)\fR
391 $ git send\-email \-\-to="person <email@example\&.com>" 00*\&.patch \fB(4)\fR
392 $ git switch master \fB(5)\fR
394 $ git log \-p ORIG_HEAD\&.\&. arch/i386 include/asm\-i386 \fB(7)\fR
395 $ git ls\-remote \-\-heads http://git\&.kernel\&.org/\&.\&.\&./jgarzik/libata\-dev\&.git \fB(8)\fR
396 $ git pull git://git\&.kernel\&.org/pub/\&.\&.\&./jgarzik/libata\-dev\&.git ALL \fB(9)\fR
397 $ git reset \-\-hard ORIG_HEAD \fB(10)\fR
404 \fB1. \fRcheckout a new branch
408 \fB2. \fRrepeat as needed\&.
410 \fB3. \fRextract patches from your branch, relative to master,
412 \fB4. \fRand email them\&.
415 \fBmaster\fR, ready to see what\(cqs new
417 \fB6. \fR\fBgit pull\fR
420 by default and merges into the current branch\&.
422 \fB7. \fRimmediately after pulling, look at the changes done upstream since last time we checked, only in the area we are interested in\&.
424 \fB8. \fRcheck the branch names in an external repository (if not known)\&.
426 \fB9. \fRfetch from a specific branch
428 from a specific repository and merge it\&.
430 \fB10. \fRrevert the pull\&.
432 \fB11. \fRgarbage collect leftover objects from reverted pull\&.
436 Push into another repository\&.
443 satellite$ git clone mothership:frotz frotz \fB(1)\fR
445 satellite$ git config \-\-get\-regexp \(aq^(remote|branch)\e\&.\(aq \fB(2)\fR
446 remote\&.origin\&.url mothership:frotz
447 remote\&.origin\&.fetch refs/heads/*:refs/remotes/origin/*
448 branch\&.master\&.remote origin
449 branch\&.master\&.merge refs/heads/master
450 satellite$ git config remote\&.origin\&.push \e
451 +refs/heads/*:refs/remotes/satellite/* \fB(3)\fR
452 satellite$ edit/compile/test/commit
453 satellite$ git push origin \fB(4)\fR
456 mothership$ git switch master
457 mothership$ git merge satellite/master \fB(5)\fR
463 \fB1. \fRmothership machine has a frotz repository under your home directory; clone from it to start a repository on the satellite machine\&.
465 \fB2. \fRclone sets these configuration variables by default\&. It arranges
467 to fetch and store the branches of mothership machine to local
468 \fBremotes/origin/*\fR
469 remote\-tracking branches\&.
473 to push all local branches to their corresponding branch of the mothership machine\&.
475 \fB4. \fRpush will stash all our work away on
476 \fBremotes/satellite/*\fR
477 remote\-tracking branches on the mothership machine\&. You could use this as a back\-up method\&. Likewise, you can pretend that mothership "fetched" from you (useful when access is one sided)\&.
479 \fB5. \fRon mothership machine, merge the work done on the satellite machine into the master branch\&.
483 Branch off of a specific tag\&.
490 $ git switch \-c private2\&.6\&.14 v2\&.6\&.14 \fB(1)\fR
491 $ edit/compile/test; git commit \-a
492 $ git checkout master
493 $ git cherry\-pick v2\&.6\&.14\&.\&.private2\&.6\&.14 \fB(2)\fR
499 \fB1. \fRcreate a private branch based on a well known (but somewhat behind) tag\&.
501 \fB2. \fRforward port all changes in
502 \fBprivate2\&.6\&.14\fR
505 branch without a formal "merging"\&. Or longhand
507 \fBgit format\-patch \-k \-m \-\-stdout v2\&.6\&.14\&.\&.private2\&.6\&.14 | git am \-3 \-k\fR
511 An alternate participant submission mechanism is using the \fBgit request\-pull\fR or pull\-request mechanisms (e\&.g as used on GitHub (www\&.github\&.com) to notify your upstream of your contribution\&.
514 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\&.
516 This section can also be used by those who respond to \fBgit request\-pull\fR or pull\-request on GitHub (www\&.github\&.com) to integrate the work of others into their history\&. A sub\-area lieutenant for a repository will act both as a participant and as an integrator\&.
527 to apply patches e\-mailed in from your contributors\&.
539 to merge from your trusted lieutenants\&.
550 \fBgit-format-patch\fR(1)
551 to prepare and send suggested alternative to contributors\&.
563 to undo botched commits\&.
575 to publish the bleeding edge\&.
579 A typical integrator\(cqs Git day\&.
586 $ git status \fB(1)\fR
587 $ git branch \-\-no\-merged master \fB(2)\fR
589 & s 2 3 4 5 \&./+to\-apply
590 & s 7 8 \&./+hold\-linus
592 $ git switch \-c topic/one master
593 $ git am \-3 \-i \-s \&./+to\-apply \fB(4)\fR
595 $ git switch \-c hold/linus && git am \-3 \-i \-s \&./+hold\-linus \fB(5)\fR
596 $ git switch topic/one && git rebase master \fB(6)\fR
597 $ git switch \-C seen next \fB(7)\fR
598 $ git merge topic/one topic/two && git merge hold/linus \fB(8)\fR
600 $ git cherry\-pick master~4 \fB(9)\fR
602 $ git tag \-s \-m "GIT 0\&.99\&.9x" v0\&.99\&.9x \fB(10)\fR
603 $ git fetch ko && for branch in master maint next seen \fB(11)\fR
605 git show\-branch ko/$branch $branch \fB(12)\fR
607 $ git push \-\-follow\-tags ko \fB(13)\fR
613 \fB1. \fRsee what you were in the middle of doing, if anything\&.
615 \fB2. \fRsee which branches haven\(cqt been merged into
617 yet\&. Likewise for any other integration branches e\&.g\&.
623 \fB3. \fRread mails, save ones that are applicable, and save others that are not quite ready (other mail readers are available)\&.
625 \fB4. \fRapply them, interactively, with your sign\-offs\&.
627 \fB5. \fRcreate topic branch as needed and apply, again with sign\-offs\&.
629 \fB6. \fRrebase internal topic branch that has not been merged to the master or exposed as a part of a stable branch\&.
633 every time from the next\&.
635 \fB8. \fRand bundle topic branches still cooking\&.
637 \fB9. \fRbackport a critical fix\&.
639 \fB10. \fRcreate a signed tag\&.
641 \fB11. \fRmake sure master was not accidentally rewound beyond that already pushed out\&.
643 \fB12. \fRIn the output from
644 \fBgit show\-branch\fR,
646 should have everything
650 should have everything
654 \fB13. \fRpush out the bleeding edge, together with new tags that point into the pushed history\&.
658 In this example, the \fBko\fR shorthand points at the Git maintainer\(cqs repository at kernel\&.org, and looks like this:
666 url = kernel\&.org:/pub/scm/git/git\&.git
667 fetch = refs/heads/*:refs/remotes/ko/*
668 push = refs/heads/master
669 push = refs/heads/next
670 push = +refs/heads/seen
671 push = refs/heads/maint
677 .SH "REPOSITORY ADMINISTRATION"
679 A repository administrator uses the following tools to set up and maintain access to the repository by developers\&.
690 to allow anonymous download from repository\&.
703 \fIrestricted login shell\fR
704 for shared central repository users\&.
715 \fBgit-http-backend\fR(1)
716 provides a server side implementation of Git\-over\-HTTP ("Smart http") allowing both fetch and push services\&.
728 provides a web front\-end to Git repositories, which can be set\-up using the
729 \fBgit-instaweb\fR(1)
733 \m[blue]\fBupdate hook howto\fR\m[]\&\s-2\u[1]\d\s+2 has a good example of managing a shared central repository\&.
735 In addition there are a number of other widely deployed hosting, browsing and reviewing solutions such as:
745 gitolite, gerrit code review, cgit and others\&.
749 We assume the following in /etc/services
756 $ grep 9418 /etc/services
757 git 9418/tcp # Git Version Control System
765 Run git\-daemon to serve /pub/scm from inetd\&.
772 $ grep git /etc/inetd\&.conf
773 git stream tcp nowait nobody \e
774 /usr/bin/git\-daemon git\-daemon \-\-inetd \-\-export\-all /pub/scm
780 The actual configuration line should be on one line\&.
783 Run git\-daemon to serve /pub/scm from xinetd\&.
790 $ cat /etc/xinetd\&.d/git\-daemon
792 # description: The Git server offers access to Git repositories
801 server = /usr/bin/git\-daemon
802 server_args = \-\-inetd \-\-export\-all \-\-base\-path=/pub/scm
803 log_on_failure += USERID
810 Check your xinetd(8) documentation and setup, this is from a Fedora system\&. Others might be different\&.
813 Give push/pull only access to developers using git\-over\-ssh\&.
815 e\&.g\&. those using:
816 \fB$ git push/pull ssh://host\&.xz/pub/scm/project\fR
822 $ grep git /etc/passwd \fB(1)\fR
823 alice:x:1000:1000::/home/alice:/usr/bin/git\-shell
824 bob:x:1001:1001::/home/bob:/usr/bin/git\-shell
825 cindy:x:1002:1002::/home/cindy:/usr/bin/git\-shell
826 david:x:1003:1003::/home/david:/usr/bin/git\-shell
827 $ grep git /etc/shells \fB(2)\fR
834 \fB1. \fRlog\-in shell is set to /usr/bin/git\-shell, which does not allow anything but
837 \fBgit pull\fR\&. The users require ssh access to the machine\&.
839 \fB2. \fRin many distributions /etc/shells needs to list what is used as the login shell\&.
843 CVS\-style shared repository\&.
850 $ grep git /etc/group \fB(1)\fR
851 git:x:9418:alice,bob,cindy,david
852 $ cd /home/devo\&.git
854 lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD \-> refs/heads/master
855 drwxrwsr\-x 2 david git 4096 Dec 4 22:40 branches
856 \-rw\-rw\-r\-\- 1 david git 84 Dec 4 22:40 config
857 \-rw\-rw\-r\-\- 1 david git 58 Dec 4 22:40 description
858 drwxrwsr\-x 2 david git 4096 Dec 4 22:40 hooks
859 \-rw\-rw\-r\-\- 1 david git 37504 Dec 4 22:40 index
860 drwxrwsr\-x 2 david git 4096 Dec 4 22:40 info
861 drwxrwsr\-x 4 david git 4096 Dec 4 22:40 objects
862 drwxrwsr\-x 4 david git 4096 Nov 7 14:58 refs
863 drwxrwsr\-x 2 david git 4096 Dec 4 22:40 remotes
864 $ ls \-l hooks/update \fB(3)\fR
865 \-r\-xr\-xr\-x 1 david git 3536 Dec 4 22:40 update
866 $ cat info/allowed\-users \fB(4)\fR
867 refs/heads/master alice\e|cindy
868 refs/heads/doc\-update bob
869 refs/tags/v[0\-9]* david
875 \fB1. \fRplace the developers into the same git group\&.
877 \fB2. \fRand make the shared repository writable by the group\&.
879 \fB3. \fRuse update\-hook example by Carl from Documentation/howto/ for branch policy control\&.
881 \fB4. \fRalice and cindy can push into master, only bob can push into doc\-update\&. david is the release manager and is the only person who can create and push version tags\&.
886 Part of the \fBgit\fR(1) suite
891 \%git-htmldocs/howto/update-hook-example.html