You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/03-git-branching/1-git-branching.asc
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -776,9 +776,9 @@ Switched to a new branch 'serverfix'
776
776
777
777
This gives you a local branch that you can work on that starts where `origin/serverfix` is.
778
778
779
-
==== Tracking Branches
779
+
==== Tracking/Upstream Branches
780
780
781
-
Checking out a local branch from a remote branch automatically creates what is called a _tracking branch_.
781
+
Checking out a local branch from a remote branch automatically creates what is called a ``tracking branch'' (or sometimes an ``upstream branch'').
782
782
Tracking branches are local branches that have a direct relationship to a remote branch.
783
783
If you’re on a tracking branch and type `git push`, Git automatically knows which server and branch to push to.
784
784
Also, running `git pull` while on one of these branches fetches all the remote references and then automatically merges in the corresponding remote branch.
Copy file name to clipboardExpand all lines: book/04-git-server/1-git-server.asc
-237Lines changed: 0 additions & 237 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -566,243 +566,6 @@ For instance, if you want the iphone project to show up on GitWeb, you make the
566
566
567
567
Now, if you commit and push the project, GitWeb will automatically start showing your iphone project.
568
568
569
-
=== Gitolite
570
-
571
-
Note: the latest copy of this section of the ProGit book is always available within the http://github.com/sitaramc/gitolite/blob/pu/doc/progit-article.mkd[gitolite documentation].
572
-
The author would also like to humbly state that, while this section is accurate, and *can* (and often *has*) been used to install gitolite without reading any other documentation, it is of necessity not complete, and cannot completely replace the enormous amount of documentation that gitolite comes with.
573
-
574
-
Git has started to become very popular in corporate environments, which tend to have some additional requirements in terms of access control.
575
-
Gitolite was originally created to help with those requirements, but it turns out that it's equally useful in the open source world: the Fedora Project controls access to their package management repositories (over 10,000 of them!)
576
-
using gitolite, and this is probably the largest gitolite installation anywhere too.
577
-
578
-
Gitolite allows you to specify permissions not just by repository, but also by branch or tag names within each repository.
579
-
That is, you can specify that certain people (or groups of people) can only push certain ``refs'' (branches or tags) but not others.
580
-
581
-
==== Installing
582
-
583
-
Installing Gitolite is very easy, even if you don't read the extensive documentation that comes with it.
584
-
You need an account on a Unix server of some kind; various Linux flavours, and Solaris 10, have been tested.
585
-
You do not need root access, assuming git, perl, and an openssh compatible ssh server are already installed.
586
-
In the examples below, we will use the `gitolite` account on a host called `gitserver`.
587
-
588
-
Gitolite is somewhat unusual as far as ``server'' software goes -- access is via ssh, and so every userid on the server is a potential ``gitolite host''.
589
-
As a result, there is a notion of ``installing'' the software itself, and then ``setting up'' a user as a ``gitolite host''.
590
-
591
-
Gitolite has 4 methods of installation.
592
-
People using Fedora or Debian systems can obtain an RPM or a DEB and install that.
593
-
People with root access can install it manually.
594
-
In these two methods, any user on the system can then become a ``gitolite host.''
595
-
596
-
People without root access can install it within their own userids.
597
-
And finally, gitolite can be installed by running a script *on the workstation*, from a bash shell.
598
-
(Even the bash that comes with msysgit will do, in case you're wondering.)
599
-
600
-
We will describe this last method in this article; for the other methods please see the documentation.
601
-
602
-
You start by obtaining public key based access to your server, so that you can log in from your workstation to the server without getting a password prompt.
603
-
The following method works on Linux; for other workstation OSs you may have to do this manually.
604
-
We assume you already had a key pair generated using `ssh-keygen`.
605
-
606
-
$ ssh-copy-id -i ~/.ssh/id_rsa gitolite@gitserver
607
-
608
-
This will ask you for the password to the gitolite account, and then set up public key access.
609
-
This is **essential** for the install script, so check to make sure you can run a command without getting a password prompt:
610
-
611
-
$ ssh gitolite@gitserver pwd
612
-
/home/gitolite
613
-
614
-
Next, you clone Gitolite from the project's main site and run the ``easy install'' script (the third argument is your name as you would like it to appear in the resulting gitolite-admin repository):
615
-
616
-
$ git clone git://github.com/sitaramc/gitolite
617
-
$ cd gitolite/src
618
-
$ ./gl-easy-install -q gitolite gitserver sitaram
619
-
620
-
And you're done!
621
-
Gitolite has now been installed on the server, and you now have a brand new repository called `gitolite-admin` in the home directory of your workstation.
622
-
You administer your gitolite setup by making changes to this repository and pushing.
623
-
624
-
That last command does produce a fair amount of output, which might be interesting to read.
625
-
Also, the first time you run this, a new keypair is created; you will have to choose a passphrase or hit enter for none.
626
-
Why a second keypair is needed, and how it is used, is explained in the ``ssh troubleshooting'' document that comes with Gitolite.
627
-
(Hey the documentation has to be good for *something*!)
628
-
629
-
Repos named `gitolite-admin` and `testing` are created on the server by default.
630
-
If you wish to clone either of these locally (from an account that has SSH console access to the gitolite account via *authorized_keys*), type:
631
-
632
-
$ git clone gitolite:gitolite-admin
633
-
$ git clone gitolite:testing
634
-
635
-
To clone these same repos from any other account:
636
-
637
-
$ git clone gitolite@servername:gitolite-admin
638
-
$ git clone gitolite@servername:testing
639
-
640
-
==== Customising the Install
641
-
642
-
While the default, quick, install works for most people, there are some ways to customise the install if you need to.
643
-
If you omit the `-q` argument, you get a ``verbose'' mode install -- detailed information on what the install is doing at each step.
644
-
The verbose mode also allows you to change certain server-side parameters, such as the location of the actual repositories, by editing an ``rc'' file that the server uses.
645
-
This ``rc'' file is liberally commented so you should be able to make any changes you need quite easily, save it, and continue.
646
-
This file also contains various settings that you can change to enable or disable some of gitolite's advanced features.
647
-
648
-
==== Config File and Access Control Rules
649
-
650
-
Once the install is done, you switch to the `gitolite-admin` repository (placed in your HOME directory) and poke around to see what you got:
651
-
652
-
$ cd ~/gitolite-admin/
653
-
$ ls
654
-
conf/ keydir/
655
-
$ find conf keydir -type f
656
-
conf/gitolite.conf
657
-
keydir/sitaram.pub
658
-
$ cat conf/gitolite.conf
659
-
#gitolite conf
660
-
# please see conf/example.conf for details on syntax and features
661
-
662
-
repo gitolite-admin
663
-
RW+ = sitaram
664
-
665
-
repo testing
666
-
RW+ = @all
667
-
668
-
Notice that ``sitaram'' (the last argument in the `gl-easy-install` command you gave earlier) has read-write permissions on the `gitolite-admin` repository as well as a public key file of the same name.
669
-
670
-
The config file syntax for gitolite is liberally documented in `conf/example.conf`, so we'll only mention some highlights here.
671
-
672
-
You can group users or repos for convenience.
673
-
The group names are just like macros; when defining them, it doesn't even matter whether they are projects or users; that distinction is only made when you *use* the ``macro''.
674
-
675
-
@oss_repos = linux perl rakudo git gitolite
676
-
@secret_repos = fenestra pear
677
-
678
-
@admins = scott # Adams, not Chacon, sorry :)
679
-
@interns = ashok # get the spelling right, Scott!
680
-
@engineers = sitaram dilbert wally alice
681
-
@staff = @admins @engineers @interns
682
-
683
-
You can control permissions at the ``ref'' level.
684
-
In the following example, interns can only push the ``int'' branch.
685
-
Engineers can push any branch whose name starts with ``eng-'', and tags that start with ``rc'' followed by a digit.
686
-
And the admins can do anything (including rewind) to any ref.
687
-
688
-
repo @oss_repos
689
-
RW int$ = @interns
690
-
RW eng- = @engineers
691
-
RW refs/tags/rc[0-9] = @engineers
692
-
RW+ = @admins
693
-
694
-
The expression after the `RW` or `RW+` is a regular expression (regex) that the refname (ref) being pushed is matched against.
695
-
So we call it a ``refex''!
696
-
Of course, a refex can be far more powerful than shown here, so don't overdo it if you're not comfortable with perl regexes.
697
-
698
-
Also, as you probably guessed, Gitolite prefixes `refs/heads/` as a syntactic convenience if the refex does not begin with `refs/`.
699
-
700
-
An important feature of the config file's syntax is that all the rules for a repository need not be in one place.
701
-
You can keep all the common stuff together, like the rules for all `oss_repos` shown above, then add specific rules for specific cases later on, like so:
702
-
703
-
repo gitolite
704
-
RW+ = sitaram
705
-
706
-
That rule will just get added to the ruleset for the `gitolite` repository.
707
-
708
-
At this point you might be wondering how the access control rules are actually applied, so let's go over that briefly.
709
-
710
-
There are two levels of access control in gitolite.
711
-
The first is at the repository level; if you have read (or write) access to *any* ref in the repository, then you have read (or write) access to the repository.
712
-
713
-
The second level, applicable only to ``write'' access, is by branch or tag within a repository.
714
-
The username, the access being attempted (`W` or `+`), and the refname being updated are known.
715
-
The access rules are checked in order of appearance in the config file, looking for a match for this combination (but remember that the refname is regex-matched, not merely string-matched).
716
-
If a match is found, the push succeeds.
717
-
A fallthrough results in access being denied.
718
-
719
-
==== Advanced Access Control with ``deny'' rules
720
-
721
-
So far, we've only seen permissions to be one or `R`, `RW`, or `RW+`.
722
-
However, gitolite allows another permission: `-`, standing for ``deny''.
723
-
This gives you a lot more power, at the expense of some complexity, because now fallthrough is not the *only* way for access to be denied, so the *order of the rules now matters*!
724
-
725
-
Let us say, in the situation above, we want engineers to be able to rewind any branch *except* master and integ.
726
-
Here's how to do that:
727
-
728
-
RW master integ = @engineers
729
-
- master integ = @engineers
730
-
RW+ = @engineers
731
-
732
-
Again, you simply follow the rules top down until you hit a match for your access mode, or a deny.
733
-
Non-rewind push to master or integ is allowed by the first rule.
734
-
A rewind push to those refs does not match the first rule, drops down to the second, and is therefore denied.
735
-
Any push (rewind or non-rewind) to refs other than master or integ won't match the first two rules anyway, and the third rule allows it.
736
-
737
-
==== Restricting pushes by files changed
738
-
739
-
In addition to restricting what branches a user can push changes to, you can also restrict what files they are allowed to touch.
740
-
For example, perhaps the Makefile (or some other program) is really not supposed to be changed by just anyone, because a lot of things depend on it or would break if the changes are not done *just right*.
741
-
You can tell gitolite:
742
-
743
-
repo foo
744
-
RW = @junior_devs @senior_devs
745
-
746
-
RW NAME/ = @senior_devs
747
-
- NAME/Makefile = @junior_devs
748
-
RW NAME/ = @junior_devs
749
-
750
-
This powerful feature is documented in `conf/example.conf`.
751
-
752
-
==== Personal Branches
753
-
754
-
Gitolite also has a feature called ``personal branches'' (or rather, ``personal branch namespace'') that can be very useful in a corporate environment.
755
-
756
-
A lot of code exchange in the git world happens by ``please pull'' requests.
757
-
In a corporate environment, however, unauthenticated access is a no-no, and a developer workstation cannot do authentication, so you have to push to the central server and ask someone to pull from there.
758
-
759
-
This would normally cause the same branch name clutter as in a centralised VCS, plus setting up permissions for this becomes a chore for the admin.
760
-
761
-
Gitolite lets you define a ``personal'' or ``scratch'' namespace prefix for each developer (for example, `refs/personal/<devname>/*`); see the ``personal branches'' section in `doc/3-faq-tips-etc.mkd` for details.
762
-
763
-
==== ``Wildcard'' repositories
764
-
765
-
Gitolite allows you to specify repositories with wildcards (actually perl regexes), like, for example `assignments/s[0-9][0-9]/a[0-9][0-9]`, to pick a random example.
766
-
This is a *very* powerful feature, which has to be enabled by setting `$GL_WILDREPOS = 1;` in the rc file.
767
-
It allows you to assign a new permission mode (``C'') which allows users to create repositories based on such wild cards, automatically assigns ownership to the specific user who created it, allows him/her to hand out R and RW permissions to other users to collaborate, etc.
768
-
This feature is documented in `doc/4-wildcard-repositories.mkd`.
769
-
770
-
==== Other Features
771
-
772
-
We'll round off this discussion with a sampling of other features, all of which, and many more, are described in great detail in the ``faqs, tips, etc'' and other documents.
773
-
774
-
**Logging**: Gitolite logs all successful accesses.
775
-
If you were somewhat relaxed about giving people rewind permissions (`RW+`) and some kid blew away ``master'', the log file is a life saver, in terms of easily and quickly finding the SHA that got hosed.
776
-
777
-
**Git outside normal PATH**: One extremely useful convenience feature in gitolite is support for git installed outside the normal `$PATH` (this is more common than you think; some corporate environments or even some hosting providers refuse to install things system-wide and you end up putting them in your own directories).
778
-
Normally, you are forced to make the *client-side* git aware of this non-standard location of the git binaries in some way.
779
-
With gitolite, just choose a verbose install and set `$GIT_PATH` in the ``rc'' files.
780
-
No client-side changes are required after that :-)
781
-
782
-
**Access rights reporting**: Another convenient feature is what happens when you try and just ssh to the server.
783
-
Gitolite shows you what repos you have access to, and what that access may be.
784
-
Here's an example:
785
-
786
-
hello sitaram, the gitolite version here is v1.5.4-19-ga3397d4
787
-
the gitolite config gives you the following access:
788
-
R anu-wsd
789
-
R entrans
790
-
R W git-notes
791
-
R W gitolite
792
-
R W gitolite-admin
793
-
R indic_web_input
794
-
R shreelipi_converter
795
-
796
-
**Delegation**: For really large installations, you can delegate responsibility for groups of repositories to various people and have them manage those pieces independently.
797
-
This reduces the load on the main admin, and makes him less of a bottleneck.
798
-
This feature has its own documentation file in the `doc/` directory.
799
-
800
-
**Gitweb support**: Gitolite supports gitweb in several ways.
801
-
You can specify which repos are visible via gitweb.
802
-
You can set the ``owner'' and ``description'' for gitweb from the gitolite config file.
803
-
Gitweb has a mechanism for you to implement access control based on HTTP authentication, so you can make it use the ``compiled'' config file that gitolite produces, which means the same access control rules (for read access) apply for gitweb and gitolite.
804
-
805
-
**Mirroring**: Gitolite can help you maintain multiple mirrors, and switch between them easily if the primary server goes down.
Copy file name to clipboardExpand all lines: book/07-git-tools/1-git-tools.asc
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -464,7 +464,7 @@ At this point, you can exit the interactive adding script and run `git commit` t
464
464
465
465
Finally, you don’t need to be in interactive add mode to do the partial-file staging – you can start the same script by using `git add -p` or `git add --patch` on the command line.
466
466
467
-
=== Stashing
467
+
=== Stashing and Cleaning
468
468
469
469
Often, when you’ve been working on part of your project, things are in a messy state and you want to switch branches for a bit to work on something else.
470
470
The problem is, you don’t want to do a commit of half-done work just so you can get back to this point later.
@@ -603,8 +603,16 @@ If you want an easier way to test the stashed changes again, you can run `git st
603
603
604
604
This is a nice shortcut to recover stashed work easily and work on it in a new branch.
605
605
606
+
==== Cleaning your Working Directory
607
+
606
608
=== Searching
607
609
610
+
=== Interactive Staging
611
+
612
+
==== Staging and Unstaging Files
613
+
614
+
==== Staging Patches
615
+
608
616
=== Rewriting History
609
617
610
618
Many times, when working with Git, you may want to revise your commit history for some reason.
0 commit comments