background preloader

Git

Facebook Twitter

Checkout only one file from git. How do you roll back (reset) a git repository to a particular commit. Using Git to manage a web site. The HTML source for my (i.e., this) web site lives in a Git repository on my local workstation. This page describes how I set things up so that I can make changes live by running just "git push web". The one-line summary: push into a remote repository that has a detached work tree, and a post-receive hook that runs "git checkout -f". The local repository It doesn't really matter how the local repository is set up, but for the sake of argument, let's suppose you're starting one from scratch. $ mkdir website && cd website $ git init Initialized empty Git repository in /home/ams/website/.git/ $ echo 'Hello, world!

' > index.html $ git add index.html $ git commit -q -m "The humble beginnings of my web site. " Anyway, however you got there, you have a repository whose contents you want to turn into a web site. The remote repository On the server, we create a new repository to mirror the local one. $ mkdir /var/www/www.example.org $ cat > hooks/post-receive #! The update process $ git push web Notes. Learn.GitHub - Git Tagging. Create signed, unsigned, or lightweight tags to permanantly mark important points in your project history Like most VCSs, Git has the ability to ‘tag’ specific points in history as being important - generally people use this to mark release points (‘v1.0’, etc). In this lesson we will learn how to list the available tags, how to create new tags, and what the different types of tags in Git are.

Simply listing the available tags in Git is very straightforward. Just type ‘git tag’. $ git tag v0.1 v1.3 This will just list them in alphabetical order, so there is no real importance in what order they list out in. You can also search for tags with a particular pattern. . $ . There are a two main types of tags in Git - lightweight and annotated. Creating an annotated tag in Git is very simple. . $ git tag -a v1.4 -m 'version 1.4' $ git tag v0.1 v1.3 v1.4 The ‘-m’ specifies a tagging message, which is stored with the tag.

A bit later, we’ll learn how to verify signed tags. tagging later. Nick Farina - Git Is Simpler Than You Think. It was about one year ago that we switched to Git. Previously, we used Subversion, through the Mac app Versions, which (rightly) holds an Apple Design Award. I made the executive decision to leave our comfy world of Versions because it seemed clear that Git was winning the Internet. There was much grumbling from my teammates, who were busy enough doing actual work thank you very much. But I pressed forward. It might as well have printed PC LOAD LETTER. “Not currently on any branch?!” Maintenance Required Git is not a Prius. By now we all know how to drive Git. Did you know the top result for “git tutorial” is this manpage on kernel.org? So instead let’s pull over, open the hood up, and poke around.

The Basics We’ll run through some basic commands to make a repository for our examples: ~$ mkdir mysite ~$ cd mysite ~/mysite$ echo "<title>All About Cats</title>" > index.html ~/mysite$ git init ~/mysite$ git add index.html ~/mysite$ git commit -m "First commit, added a title. " With me so far? How do I edit an incorrect commit message in Git.

Changing Git History. This document describes how to modify commit messages in Git after the fact. Changing the Last Commit Message If you only want to modify your last commit message, it is very simple. Just run $ git commit --amend That will drop you into your text exitor and let you change the last commit message. Changing Multiple Commit Messages Now let's assume that you want to modify either multiple commit messages, or a commit message several commits back. If you want to change the last 3 commit messages, or any of the commit messages up to that point, supply 'HEAD~3' to the git rebase -i command. $ git rebase -i HEAD~3 Warning: every commit you see in this list will be re-written, whether you change the message or not. Running this command will give you a list of commits in your text editor that looks something like this: Change the word 'pick' to the work 'edit' for each of the commits you want to change the message for.

These instructions tell you exactly what to do. . $ git rebase --continue. Git - How can I roll back 1 commit. Git Submodules. It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other. Here’s an example. Suppose you’re developing a web site and creating Atom feeds. Instead of writing your own Atom-generating code, you decide to use a library. Git addresses this issue using submodules. Starting with Submodules Suppose you want to add the Rack library (a Ruby web server gateway interface) to your project, possibly maintain your own changes to it, but continue to merge in upstream changes.

Now you have the Rack project under a subdirectory named rack within your project. First you notice the .gitmodules file. If you have multiple submodules, you’ll have multiple entries in this file. Superprojects.