Open main menu

Changes

2,162 bytes added ,  13:02, 31 March 2020
remove template
Why do we have git? Because [http://whygitisbetterthanx.com Git is better than X] Now that we have the "My DVCS is better than your DVCS" argument out of the way, you can actually get some valuable insights from that website if you are interested in comparing Git with Mercurial, Bazaar, Subversion or Perforce. If I had to single out one primary advantage of Git, it would be that it actually features branching and merging.
Repo visibility is completely customizable, as are individual permissions to write to repos. I've installed a system called gitosis to handle the privileges through a special git repository. It uses Public Key cryptography rather than granting SSH accounts to everyone. This makes it really easy to do your work securely without even needing a password. For the curious, the actual mechanics of gitosis are detailed at [http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way scie.nti.st]. Although that link may still work, there is also https://git-scm.com/book/en/v1/Git-on-the-Server-Gitosis.
{{Messagebox |
}}
You might want to read about how we [[Git/migrating to git|migrate from Subversion to Git]] or how [http://julienrenaux.fr/2014/02/28/leading-the-svn-to-git-migration/ migrate others have done it] == Initial Configuration ==In your [https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup first time setting up Git on a new computer], you want to configure your username and email among other settings.<source lang="bash">git config --global user.name "Greg Rundlett"git config --global user.email greg@freephile.comgit config --global core.editor vimgit config --global diff.tool meldgit config --global --add color.ui true# store password in memory for an hourgit config --global credential.helper 'cache --timeout=3600'  # recent packaged versions of git might be 1.8.3.1 (CentOS 7.4) whereas the current available is 2.15.1# push.default is unset; its implicit value is changing in# Git 2.0 from Subversion 'matching' to 'simple'. To squelch this message# and adopt the new behavior now, use:git config --global push.default simple</source>=== Example .gitconfig ===<code>git config --global -e</code> and paste in the following:<source lang="ini">[user] name = Greg Rundlett email = greg@freephile.com [alias] co = checkout ci = commit unstage = reset HEAD wu = log --stat origin..@{0} wup = log -p origin..@{0} lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative [core] excludesfile = /home/greg/.gitignore_global editor = vim [color] ui = true [credential] helper = cache --timeout=3600 # ------------------ M E R G E -------------------------[merge] tool = meld [mergetool "meld"] cmd = meld --auto-merge \"$LOCAL\" \"$BASE\" \"$REMOTE\" --output \"$MERGED\" --label \"MERGE (REMOTE BASE MY)\" trustExitCode = false [mergetool] # don't ask if we want to skip merge prompt = false  # don't create backup *.orig files keepBackup = false # ------------------ D I F F -------------------------[diff] guitool = meld [difftool "meld"] cmd = meld \"$LOCAL\" \"$REMOTE\" --label \"DIFF (Original v. Mine)\"  [push] default = simple[gitreview] remote = origin[help] format = web[web]# browser = google-chrome browser = firefox</source> {{Highlight|text = If you want to browse the git help in your browser (as above), then make sure you <code>sudo apt-get install git-doc</code> to get the HTML files}} == Decentralized Workflow and Branching Model ==Here's a good explanation on how most groups use Git in a successful branching model for development, "master", release branches, hotfixes, etc.http://nvie.com/posts/a-successful-git-branching-model/  == Submodules ==Using multiple repositories to compose your project. See https://git-scm.com/book/en/v2/Git]-Tools-Submodules <source lang="bash">git init myprojectcd myprojectgit submodule add git@github.com:example.com/htdocs.git websitegit submodule add https://gerrit.wikimedia.org/r/p/mediawiki/core.git mediawikigit submodule add https://gitlab.com/Aranad/tools.git odtoolscd mediawiki/git checkout REL1_31cd ../git commit -m 'initial commit'git diff --submodulegit config --global diff.submodule loggit diffgit config -f .gitmodules submodule.mediawiki.branch REL1_31git submodule update --remotegit statusgit commit -am 'tracking REL1_31 in the mediawiki submodule'git config status.submodulesummary 1git log -p --submodulecd mediawiki/git submodule update --remote --mergegit config alias.sdiff '!'"git diff && git submodule foreach 'git diff'" git config alias.spush 'push --recurse-submodules=on-demand'git config alias.supdate 'submodule update --remote --merge'</source>
== Tools ==
[[File:Meza.big.picture.pdf|thumb|Meza Big Picture|right]]
* http://git-scm.com/tools
* http://github.com/guides/using-the-egit-eclipse-plugin-with-github
* [https://github.com/esc/git-big-picture Git Big Picture] is a nice visualization tool that produces images like the one on the right.
== Reporting ==
}'
</source>
 
== Visualizing ==
There are a lot of ways to use the <code>git log</code> command to visualize your history. Everything from <code>git log --pretty=oneline</code> or <code>git log --graph --oneline</code> to <code>git log --graph --full-history --all --color --date=short --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%ad %s"</code> which you probably want to put into your <code>~/.gitconfig</code> as some alias because who the heck is going to remember that one?<ref>https://stackoverflow.com/questions/1838873/visualizing-branch-topology-in-git</ref> Of course there are also many GUI clients.
== Documentation ==
* http://flavio.castelli.name/2007/09/04/howto_use_git_with_svn/
== Git Repo Hosting ==
It seems everyone uses GitHub these days (~8 million users, 20 million projects). It's not a bad solution, but there are some drawbacks, and whether you're just looking to host your own project or setup enterprise-wide git hosting, there are other ways to host your projects in Git. Let's take a look at some options.
 
<ol>
<li>'''GitHub''' can make it a bit easier for developers who are used to working with svn because they have 'built-in' [https://github.com/blog/1178-collaborating-on-github-with-subversion svn client] support.<ref>Anyone can use <code>git svn</code> and all the other built-in git subversion bridging commands, GitHub simplifies how to do it.</ref> GitHub [https://enterprise.github.com/home Enterprise] can be installed on your own servers. GitHub costs money for private repos.
<li>[https://about.gitlab.com/ '''GitLab'''] is the "popular" alternative to GitHub that comes in "Community", "Enterprise" and "Cloud" versions. They say it's "[https://about.gitlab.com/better-than-github/ better than GitHub]" One nice thing that I note is that they've integrated git-annex for large binary support. This is a nice plus. (I've personally used git-annex as a file backup system -- like DropBox. In my case, it was to make backups of UbuntuOne when that service was discontinued.) You can install GitLab in minutes on your own server. It's costs if you want the [https://about.gitlab.com/features/#compare Enterprise] version.<li>'''GitBlit''' is "a pure Java git server that just works". It's a "true" open source project run by [https://www.linkedin.com/pub/james-moger/8b/3a3/65b James Moger] and scores of other contributors. GitBlit is self-hosted, so you can get a feel for it quickly by looking at the projects own [https://dev.gitblit.com/ source code]. It does have some nice [http://gitblit.com/features.html features].
 
The current Wikimedia Ops team is using [http://gitblit.com/ Gitblit] to drive https://git.wikimedia.org/ Gitblit is an open-source, pure Java stack for managing, viewing, and serving Git repositories.
It's designed primarily as a tool for small workgroups who want to host centralized repositories. It comes in two options: GO is an integrated single stack solution so you can really get up and running in no time flat; and there is a WAR version (assumes you already have a servlet container like Jetty or Tomcat.) Gitblit requires a Java 7 Runtime Environment (JRE) Gitblit comes with a lot of [http://gitblit.com/features.html features]
</ol>
== Background ==
Only in /var/www/drupal/sites: www.example.org
</pre>
 
== Git Repo Hosting ==
See [[Git repo hosting]]
== Building a Git server ==
[[Category:Howto]]
[[Category:Subversion]]
[[Category:SystemAdministrationSystem Administration]]