1. Learn Git
    1. Learn Git with Bitbucket Cloud
      1. Create a Git repository
      2. Copy your Git repository and add files
      3. Pull changes from your Git repository on Bitbucket Cloud
      4. Use a Git branch to merge a file
    2. Learn about code review in Bitbucket Cloud
      1. Fork a teammate's repository
      2. Copy your fork and make a change to the repository
      3. Create a pull request
  2. Getting Started
    1. What is version control
      1. Benefits of version control
    2. What is Git
      1. Performance
      2. Security
      3. Flexibility
      4. Version control with Git
    3. Why Git for your organization
      1. Git for developers
      2. Git for marketing
      3. Git for product management
      4. Git for designers
      5. Git for customer support
      6. Git for human resources
      7. Git for anyone managing a budget
    4. Install Git
      1. Install Git on Mac OS X
      2. Install Git on Windows
      3. Install Git on Linux
    5. Setting up a repository
      1. git init
      2. git clone
      3. git config
    6. Saving changes
      1. git add
      2. git commit
    7. Git Stash
      1. .gitignore
        1. Inspecting a repository
          1. git status
          2. git log
        2. Viewing old commits
          1. Undoing Changes
            1. git checkout
            2. git revert
            3. git reset
            4. git clean
          2. Rewriting history
            1. git commit --amend
            2. git rebase
            3. git rebase -i
            4. git reflog
        3. Collaborating
          1. Syncing
            1. git remote
            2. git fetch
            3. git pull
            4. git push
          2. Making a Pull Request
            1. How it works
            2. Example
            3. Where to go from here
          3. Using Branches
            1. git branch
            2. git checkout
            3. git merge
          4. Comparing Workflows
            1. Centralized Workflow
            2. Feature Branch Workflow
            3. Gitflow Workflow
            4. Forking Workflow
        4. Migrating to Git
          1. SVN to Git - prepping for the migration
            1. For administrators
            2. Basic Git commands
            3. Git Migration Tools
            4. For developers
          2. Migrate to Git from SVN
            1. Prepare
              1. Convert
                1. Synchronize
                  1. Share
                    1. Migrate
                      1. Perforce to Git - why to make the move
                        1. Migrating from Perforce to Git
                        2. Advanced Tips
                          1. Advanced Git Tutorials
                            1. Merging vs. Rebasing
                              1. Conceptual Overview
                              2. The Golden Rule of Rebasing
                              3. Workflow Walkthrough
                              4. Summary
                            2. Reset, Checkout, and Revert
                              1. Commit-level Operation
                              2. File-level Operations
                              3. Summary
                            3. Advanced Git log
                              1. Formatting Log Output
                              2. Filtering the Commit History
                              3. Summary
                            4. Git Hooks
                              1. Conceptual Overview
                              2. Local Hooks
                              3. Server-side Hooks
                              4. Summary
                            5. Refs and the Reflog
                              1. Hashes
                              2. Refs
                              3. Packed Refs
                              4. Special Refs
                              5. Refspecs
                              6. Relative Refs
                              7. The Reflog
                              8. Summary
                            6. Git LFS

                            Use Git even if your team doesn't: git-svn tips and tricks

                            Nicola PaolucciNicola Paolucci
                            Back to list

                            Before joining Atlassian, I'd been working on various projects that still used Subversion (SVN) as their version control system. I had moved to Git already years before, and I wanted to keep using it as much as possible.

                            Luckily I could use git-svn: An incredibly complete solution to interact with Subversion repositories without leaving the comfort of the Git power toolset. But there are gotchas. This post assumes you are already a little bit acquainted with git-svn, and you know how to interact with a SVN repository using it.

                            The list below contains all the tricks and tips I had to research and integrate in my workflow to keep using Git joyfully in conjunction with SVN. Enjoy!

                            Setting up the files to ignore

                            You should make sure that Git ignores the same files SVN does. The simplest trick is to append the list of svn:ignore files to the default git exclude file:

                            git svn show-ignore >> .git/info/exclude

                            An alternative method is the magical update-index:

                            git update-index --assume-unchanged files to ignore

                            This is quite a fine trick, and I've consistently used in the past year. If you need more information, have a look at this post on Stackoverflow. If you use the latter method, how do you find out later that a file has been ignored in Git? You can use this:

                            git ls-files -v | grep ^[a-z] | sed -e 's/^h\ //'

                            NOTE: update-index is an advanced command that manipulates the index directly, use it with care!

                            Shallow clone big repositories

                            I've worked with SVN codebases above 1.5Gb for a full checkout. In similar scenarios, checking out the entire history commit by commit – the way git-svn does – can be lengthy, as the repository is simply too big. The way around this issue is to create a shallow clone of the repository; instead of copying the entire history of the project you just copy the last n commits and proceed from there. For example:

                            git svn clone -s -r604:HEAD http://nick@svn.xxxxxx.com/repos/ -T trunk -b branches -t tags

                            Where "604" must be replaced with the earlier revision you want to keep. Mandatory Stackoverflow reference.

                            If you added the .svn folders by mistake in Git

                            Sooner or later you'll run into a few snags. For example one time I didn't use git-svn, I just checked out a project from SVN but I wanted to do my own tracking using Git. At that time I mistakenly added the .svn folders to the index (staging area) in git. How to keep those important files but remove them from the index? Tricky! Here's how to untrack files without actually deleting them in git:

                            git status -s | grep .svn | awk {'print $3'} | xargs git rm --cached

                            The keyword here is --cached that operates on the index and not in the working directory. Very clearly explained in this chapter on progit.

                            What to do when a SVN repository moves

                            When a SVN repository moves (or when you have to access it via VPN and do some smart tunneling that will change its address) you have to follow the correct procedure to avoid a full re-checkout. The first method listed at the git wiki is the one with which I had consistent success. Directly from the wiki here is the important part:

                            • Edit the svn-remote URL in .git/config to point to the new domain name or IP Address.
                            • Run git svn fetch - This needs to fetch at least one new revision from svn!
                            • Change svn-remote url back to the original url.
                            • Run git svn rebase -l to do a local rebase (with the changes that came in with the last fetch operation).
                            • Change svn-remote url back to the new url.
                            • Run git-svn rebase. It should now work normally again!

                            This will only work if the git-svn fetch step actually fetches anything!


                            Working with Git is a joy for me. You have total freedom and control, you can commit endlessly, reformat your commits, squash them into clean ones, and branch like crazy. You can bring the same joy with you even if you have to interact with SVN. I've done it for two years straight, and it works beautifully.

                            When your whole team is ready to migrate to Git, it's nice to have a comprehensive step-by-step guide. So we wrote one:

                            the Easy SVN to Git migration guide!