All Possible Interview Questions on Git, Github and Gitlab

interview-questions-on-git-github-gitlab

  • What is GIT?
  • What is a repository in GIT?
  • What is the command you can use to write a commit message?
  • What is the difference between GIT and SVN and other CM systems?
    • Answers –
      • Cheap Local Branching
      • Everything is Local
      • Git is Fast
      • Git is Small
      • The Staging Area
      • Distributed
      • Any Workflow
      • Easy to Learn
      • Git is the new standard
  • What are the advantages of using GIT?
  • What language is used in GIT?
  • What is the function of ‘GIT PUSH’ in GIT?
  • Why GIT better than Subversion?
  • What is “Staging Area” or “Index” in GIT?
  • What is GIT stash?
  • What is GIT stash drop?
  • How will you know in GIT if a branch has been already merged into master?
  • What is the function of git clone?
  • What is the function of ‘git config’?
  • What does commit object contain?
  • How can you create a repository in Git?
  • What is ‘head’ in git and how many heads can be created in a repository?
  • What is the purpose of branching in GIT?
  • What is the common branching pattern in GIT?
  • How can you bring a new feature in the main branch?
  • What is a ‘conflict’ in git?
  • How can conflict in git resolved?
  • To delete a branch what is the command that is used?
  • What is another option for merging in git?
  • What is the syntax for “Rebasing” in Git?
  • What is the difference between ‘git remote’ and ‘git clone’?
  • What is GIT version control?
  • Mention some of the best graphical GIT client for LINUX?
  • What is Subgit? Why to use Subgit?
  • What is the function of ‘git diff ’ in git?
  • What is ‘git status’ is used for?
  • What is the difference between the ‘git diff ’and ‘git status’?
  • What is the function of ‘git checkout’ in git?
  • What is the function of ‘git rm’?
  • What is the function of ‘git stash apply’?
  • What is the use of ‘git log’?
  • What is ‘git add’ is used for?
  • What is the function of ‘git reset’?
  • What is git Is-tree?
  • How git instaweb is used?
  • What does ‘hooks’ consist of in git?
  • Explain what is commit message?
  • How can you fix a broken commit?
  • What is ‘bare repository’ in GIT?
  • How do you start Git and what is the process called?
  • How do you put your local repository (repo) on the GitHub server?
  • How to delete the working branch?
  • What as the strength and weaknesses of the software?
  • But I am quite happy with Subversion (SVN). What is all this fuss about? Is there a substantial trend for distributed versioning control systems (DVCS)?
  • Isn’t DVCS something for small teams and startups? I am working in a very big company. We value established things way more than the cutting edge stuff, that may not be here to stay.
  • Okay. Let’s say we go with DVCS. Why should I take git and not mercurial?
  • I like, that git allows our developers to host the complete repository on his local machine. That makes software development faster. So why do
  • you I need Stash on top?
  • How do you use this rights management with Stash? How does it work? Will developers only get have a repository? Is that still functional then?
  • What is a pull request? What is this for? Aren’t we sharing all code with all developers and let everyone do what he wants? Is that only for
  • hierachical software development methods?
  • How would you summarize the advantages of Stash in short?
  • What is the one reason, that your customers give Atlassian today on why they purchase Stash?
  • Can you offer us a small sneak peak into your upcoming next releases? Is there anything, that you can share first hand with us?
  • What is your general roadmap for stash? Where do you want to position it near and long term?
  • Do you ultimately plan to support Mercurial? When is a good time to buy Stash, if I run with hg at the moment?
  • Why should I go for Stash in favor of GitHub Enterprise or RhodeCode?
  • Why is Stash a separated product and not part of Bitbucket. I could imagine seeing Bitbucket Enterprise resembling GitHub Enterprise.
  • Is Atlassian using Stash internally in software development? If not, why not?
  • Wouldn’t it be interesting to combine Fisheye, Crucible and Stash in one product?
  • What is the difference between GIT and SVN?
  • What are the advantages of using GIT over other tools?
  • What is GIT stash?
  • What does commit object contain?
  • How can conflict in git resolved?
  • What is the difference between ‘git remote’ and ‘git clone’?
  • Mention some of the best graphical GIT client for LINUX?
  • What does ‘hooks’ consist of in git?
  • What is ‘bare repository’ in GIT?
  • Add a line to the some.txt file and then throw out all changes since the last commit.
  • Why GIT better than Subversion?
  • How to troubleshoot Git?
  • How to troubleshoot GitLab?
  • How to troubleshoot Github?
  • How to take Gitlab backup
  • What is Git Objects? explain about Tree, blob, commit, tag, branch objects?
  • How git Object storage works?
  • What is SHA1?
  • Introduction to the GitHub platform
  • github Distributed version control synchronization
  • github Project management and repository integration
  • github Multiple remotes and Fork maintenance
  • github Remote repository interaction and dependencies
Tagged : / / / / / / / / / / / / /

Git Troubleshooting | Git Troubleshooting Techniques

git-troubleshooting

export GIT_CURL_VERBOSE=1

git push -u origin –all –verbose

git config –list

&

GIT_CURL_VERBOSE=1 git push

&

export GIT_CURL_VERBOSE=1

git push

git config --global http.postBuffer

There are useful to debug, long running Git Commands or Git Commands that seem to be hanged for some reason,

Git has an in-built functionality for us to peek into what is running behind the scenes of a git command, just add GIT_TRACE=1 before ANY git command to get additional info, for example:

Other Flags that we can use are : GIT_CURL_VERBOSE=1, -v or –verbose

[server@user sp-server-branches]$ GIT_TRACE=1 git clone

https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide

https://drupal.org/node/1065850

http://mattberther.com/2013/12/29/pushing-large-git-repos-with-ssh

http://ocaoimh.ie/2008/12/10/how-to-fix-ssh-timeout-problems/

http://unix.stackexchange.com/questions/3026/what-do-the-options-serveraliveinterval-and-clientaliveinterval-in-sshd-conf

Tagged : / / / / / / / / /

Why Git is Better than X | Git or X

why-git-is-better-than-x

Cheap Local Branching

svn perforce

Everything is Local

bzr svn perforce

Git is Fast

hg bzr svn perforce

The Staging Area

svn perforce

Distributed

svn perforce

Any Workflow

hg svn perforce

GitHub

perforce

Easy to Learn

hg bzr svn perforce

Git is the new standard

Tagged : / / / / / / / / / / / / /

Git Training | Git Course | Git Trainer | Online | Classroom | India

git-training

Click Here

scmGalaxy is a community initiatives based on Software configuration management that helps community members to optimize their software development process, Software Development Life Cycle optimization, Agile Methodologies and improve productivity across all aspects of Java development, including Build Scripts, Testing, Issue Tracking, Continuous Integration, Code Quality and more. scmGalaxy group that helps organisations optimize their software development process. We provide consulting, training and mentoring services in Agile Development Practices such as Version Management, Continuous Integration, Build Management, Test-Driven Development, Acceptance-Test Driven Development, Build Automation, Code Quality Practices and Automated Testing.

We provide job oriented training in the area of Configuration management, Build and Release Engineering. Candidates with engineering or software background and looking to either start or change their career to Build and Release Engineering, would benefit most from this training. Instructor-led training course offered in India, Bangalore, Delhi, Pune, Mumbai and Hydrabad. Instructor is an expert in Software configuration management, Build and release engineering with more than 15 years industry experience in india.The Goal of the course make the training attendants equip with all the concepts of build and release engineering.

Contact us at info@scmGalaxy.com

Course Objectives
To bring your team up to speed with agile development, We can also run the from Continuous Integration to Continuous Delivery with autoamted course within your premises.

Course Schedule
This course is an intensive 1-day & 2-day workshop with a mixture of teaching and lab exercises. Currently, this course is offered exclusively as an on-site course. Please contact us for more details.

Audience
This is a hands-on, practical course designed to teach specialised skills for real-world development situations. It is thus primarily aimed at a SCM Engineer, Build/Release Engineer and developer audience.

Approach
The course is modular and flexible – depending on specific student needs and requests. Through our trainings, you benefit from the wide experience and architectural expertise of our team. We bring that experience to you in an highly interactive, intensely hands-on setting.

Assumptions
We assume participants have a reasonable understanding of Development in any language as well as a basic understanding of the Software Development Life Cycle.

Lab Work
All our courses are above all practical in nature. We believe that the best way to learn is by doing. So the course contains approximately 80% lab work.

Learning Resources
Each registrant will receive a copy of the student notes and lab solutions, a certificate of completion, and a CD containing all the tools covered in the course and CD containing all the tools covered in the course.

Contact Us
This course is provided on-site, and can be tailored to your particular requirements. If you would like our trainings delivered at your premises, or for any additional information please contact us. Please email us at info@scmGalaxy.com

Course outline

The basic course program is outlined here:

1. What is Git?

  • Understanding version control
  • The history of Git
  • About distributed version control
  • Who should use Git?

2. Installing Git

  • Installing Git on a Mac
  • Installing Git on Windows
  • Installing Git on Linux
  • Configuring Git
  • Exploring Git auto-completion
  • Using Git help

3. Getting Started

  • Initializing a repository
  • Understanding where Git files are stored
  • Performing your first commit
  • Writing commit messages
  • Viewing the commit log

4. Git Concepts and Architecture

  • Exploring the three-trees architecture
  • The Git workflow
  • Using hash values (SHA-1)
  • Working with the HEAD pointer

5. Making Changes to Files

  • Adding files
  • Editing files
  • Viewing changes with diff
  • Viewing only staged changes
  • Deleting files
  • Moving and renaming files
  • Using Git with a Real Project
  • Introducing the Explore California web site
  • Initializing Git
  • Editing the support phone number
  • Editing the backpack file name and links

7. Undoing Changes

  • Undoing working directory changes
  • Unstaging files
  • Amending commits
  • Retrieving old versions
  • Reverting a commit
  • Using reset to undo commits
  • Demonstrating a soft reset
  • Demonstrating a mixed reset
  • Demonstrating a hard reset
  • Removing untracked files

8. Ignoring Files

  • Using .gitignore files
  • Understanding what to ignore
  • Ignoring files globally
  • Ignoring tracked files
  • Tracking empty directories

9. Navigating the Commit Tree

  • Referencing commits
  • Exploring tree listings
  • Getting more from the commit log
  • Viewing commits
  • Comparing commits

10. Branching

  • Branching overview
  • Viewing and creating branches
  • Switching branches
  • Creating and switching branches
  • Switching branches with uncommitted changes
  • Comparing branches
  • Renaming branches
  • Deleting branches
  • Configuring the command prompt to show the branch

11. Merging Branches

  • Merging code
  • Using fast-forward merge vs. true merge
  • Merging conflicts
  • Resolving merge conflicts
  • Exploring strategies to reduce merge conflicts

12. Stashing Changes

  • Saving changes in the stash
  • Viewing stashed changes
  • Retrieving stashed changes
  • Deleting stashed changes

13. Remotes

  • Using local and remote repositories
  • Setting up a GitHub account
  • Adding a remote repository
  • Creating a remote branch
  • Cloning a remote repository
  • Tracking remote branches
  • Pushing changes to a remote repository
  • Fetching changes from a remote repository
  • Merging in fetched changes
  • Checking out remote branches
  • Pushing to an updated remote branch
  • Deleting a remote branch
  • Enabling collaboration
  • A collaboration workflow

14. Tools and Next Steps

  • Setting up aliases for common commands
  • Using SSH keys for remote login
  • Exploring integrated development environments
  • Exploring graphical user interfaces
  • Understanding Git hosting

Conclusion

Git Training In Bangalore | Git Training in India | Git Training in Hydrabad | Git Training in Delhi | Git Training in Pune | Git Trainer In Bangalore | Git Trainer in India | Git Trainer in Hydrabad | Git Trainer in Delhi | Git Trainer in Pune

Tagged : / / / / / / / / / / / / / / / / / / / / / /

GIT Tutorial – Branching and Merging

git-branching-and-merging-tutorial

Tagged : / / / / / / / / / / / / / /

O’Reilly Webcast: Git in One Hour

git-in-one-hour

 

Please click this link to find video for the O’Reilly Webcast: Git in One Hour

Tagged : / / / / / / / / / / /

Introduction to Git with Scott Chacon of GitHub | Git Overview

git-introduction

 

Please go through the link to find video for the Introduction to Git with Scott Chacon of GitHub

Tagged : / / / / / / / / /

BASH aliases for GIT | Bash Git Aliases Reference

bash-aliases-for-git

BASH aliases for GIT

Following BASH aliases can be used in ~/.BASHRC

alias g = “git status”
alias ga = “git add”
alias gaa = “git add .”
alias gc = “git commit -m”
alias gca = “git commit -am”
alias gb = “git branch”
alias gbd = “git branch -d”
alias gco = “git checkout”
alias gcob = “git checkout -b”
alias gm = “git merge”
alias gr = “git rebase”
alias gl = “git log”
alias gs = “git show”
alias gd = “git diff”
alias gbl = “git blame”
alias gps = “git push”
alias gpl = “git pull”

Tagged : / / / / / / / /

A Successful Git branching model | Git branching model Guide

successful-git-branching-model

I was reading article and thought to repost here.

It focuses around Git as the tool for the versioning of all of our source code.

Why git?

For a thorough discussion on the pros and cons of Git compared to centralized source code control systems, see the web. There are plenty of flame wars going on there. As a developer, I prefer Git above all other tools around today. Git really changed the way developers think of merging and branching. From the classic CVS/Subversion world I came from, merging/branching has always been considered a bit scary (“beware of merge conflicts, they bite you!”) and something you only do every once in a while.

But with Git, these actions are extremely cheap and simple, and they are considered one of the core parts of your daily workflow, really. For example, in CVS/Subversion books, branching and merging is first discussed in the later chapters (for advanced users), while in every Git book, it’s already covered in chapter 3 (basics).

As a consequence of its simplicity and repetitive nature, branching and merging are no longer something to be afraid of. Version control tools are supposed to assist in branching/merging more than anything else.

Enough about the tools, let’s head onto the development model. The model that I’m going to present here is essentially no more than a set of procedures that every team member has to follow in order to come to a managed software development process.

Decentralized but centralized

The repository setup that we use and that works well with this branching model, is that with a central “truth” repo. Note that this repo is only considered to be the central one (since Git is a DVCS, there is no such thing as a central repo at a technical level). We will refer to this repo as origin, since this name is familiar to all Git users.

Each developer pulls and pushes to origin. But besides the centralized push-pull relationships, each developer may also pull changes from other peers to form sub teams. For example, this might be useful to work together with two or more developers on a big new feature, before pushing the work in progress to origin prematurely. In the figure above, there are subteams of Alice and Bob, Alice and David, and Clair and David.

Technically, this means nothing more than that Alice has defined a Git remote, named bob, pointing to Bob’s repository, and vice versa.

The main branches

At the core, the development model is greatly inspired by existing models out there. The central repo holds two main branches with an infinite lifetime:

  • master
  • develop

The master branch at origin should be familiar to every Git user. Parallel to the master branch, another branch exists called develop.

We consider origin/master to be the main branch where the source code of HEAD always reflects aproduction-ready state.

We consider origin/develop to be the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release. Some would call this the “integration branch”. This is where any automatic nightly builds are built from.

When the source code in the develop branch reaches a stable point and is ready to be released, all of the changes should be merged back into master somehow and then tagged with a release number. How this is done in detail will be discussed further on.

Therefore, each time when changes are merged back into master, this is a new production release by definition. We tend to be very strict at this, so that theoretically, we could use a Git hook script to automatically build and roll-out our software to our production servers everytime there was a commit on master.

Supporting branches

Next to the main branches master and develop, our development model uses a variety of supporting branches to aid parallel development between team members, ease tracking of features, prepare for production releases and to assist in quickly fixing live production problems. Unlike the main branches, these branches always have a limited life time, since they will be removed eventually.

The different types of branches we may use are:

  • Feature branches
  • Release branches
  • Hotfix branches

Each of these branches have a specific purpose and are bound to strict rules as to which branches may be their originating branch and which branches must be their merge targets. We will walk through them in a minute.

By no means are these branches “special” from a technical perspective. The branch types are categorized by how we use them. They are of course plain old Git branches.

Feature branches

May branch off from: develop
Must merge back into: develop
Branch naming convention: anything except masterdevelop,release-*, or hotfix-*

Feature branches (or sometimes called topic branches) are used to develop new features for the upcoming or a distant future release. When starting development of a feature, the target release in which this feature will be incorporated may well be unknown at that point. The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged back into develop(to definitely add the new feature to the upcoming release) or discarded (in case of a disappointing experiment).

Feature branches typically exist in developer repos only, not inorigin.

Creating a feature branch

When starting work on a new feature, branch off from the develop branch.

$ git checkout -b myfeature develop Switched to a new branch "myfeature"

Incorporating a finished feature on develop

Finished features may be merged into the develop branch definitely add them to the upcoming release:

$ git checkout develop Switched to branch 'develop' $ git merge --no-ff myfeature Updating ea1b82a..05e9557 (Summary of changes) $ git branch -d myfeature Deleted branch myfeature (was 05e9557). $ git push origin develop

The --no-ff flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature. Compare:

In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the --no-ff flag was used.

Yes, it will create a few more (empty) commit objects, but the gain is much bigger that that cost.

Unfortunately, I have not found a way to make --no-ff the default behaviour of git mergeyet, but it really should be.

Release branches

May branch off from: develop
Must merge back into: develop and master
Branch naming convention: release-*

Release branches support preparation of a new production release. They allow for last-minute dotting of i’s and crossing t’s. Furthermore, they allow for minor bug fixes and preparing meta-data for a release (version number, build dates, etc.). By doing all of this work on a release branch, the develop branch is cleared to receive features for the next big release.

The key moment to branch off a new release branch from develop is when develop (almost) reflects the desired state of the new release. At least all features that are targeted for the release-to-be-built must be merged in to develop at this point in time. All features targeted at future releases may not—they must wait until after the release branch is branched off.

It is exactly at the start of a release branch that the upcoming release gets assigned a version number—not any earlier. Up until that moment, the develop branch reflected changes for the “next release”, but it is unclear whether that “next release” will eventually become 0.3 or 1.0, until the release branch is started. That decision is made on the start of the release branch and is carried out by the project’s rules on version number bumping.

Creating a release branch

Release branches are created from the develop branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of develop is ready for the “next release” and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number:

$ git checkout -b release-1.2 develop Switched to a new branch "release-1.2" $ ./bump-version.sh 1.2 Files modified successfully, version bumped to 1.2. $ git commit -a -m "Bumped version number to 1.2" [release-1.2 74d9424] Bumped version number to 1.2 1 files changed, 1 insertions(+), 1 deletions(-)

After creating a new branch and switching to it, we bump the version number. Here, bump-version.sh is a fictional shell script that changes some files in the working copy to reflect the new version. (This can of course be a manual change—the point being that some files change.) Then, the bumped version number is committed.

This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch (rather than on the developbranch). Adding large new features here is strictly prohibited. They must be merged intodevelop, and therefore, wait for the next big release.

Finishing a release branch

When the state of the release branch is ready to become a real release, some actions need to be carried out. First, the release branch is merged into master (since every commit onmaster is a new release by definition, remember). Next, that commit on master must be tagged for easy future reference to this historical version. Finally, the changes made on the release branch need to be merged back into develop, so that future releases also contain these bug fixes.

The first two steps in Git:

$ git checkout master Switched to branch 'master' $ git merge --no-ff release-1.2 Merge made by recursive. (Summary of changes) $ git tag -a 1.2

The release is now done, and tagged for future reference.
Edit: You might as well want to use the -s or -u <key> flags to sign your tag cryptographically.

To keep the changes made in the release branch, we need to merge those back intodevelop, though. In Git:

$ git checkout develop Switched to branch 'develop' $ git merge --no-ff release-1.2 Merge made by recursive. (Summary of changes)

This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit.

Now we are really done and the release branch may be removed, since we don’t need it anymore:

$ git branch -d release-1.2 Deleted branch release-1.2 (was ff452fe).

Hotfix branches

May branch off from: master
Must merge back into: develop and master
Branch naming convention: hotfix-*

Hotfix branches are very much like release branches in that they are also meant to prepare for a new production release, albeit unplanned. They arise from the necessity to act immediately upon an undesired state of a live production version. When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the master branch that marks the production version.

The essence is that work of team members (on the develop branch) can continue, while another person is preparing a quick production fix.

Creating the hotfix branch

Hotfix branches are created from the master branch. For example, say version 1.2 is the current production release running live and causing troubles due to a severe bug. But changes on develop are yet unstable. We may then branch off a hotfix branch and start fixing the problem:

$ git checkout -b hotfix-1.2.1 master Switched to a new branch "hotfix-1.2.1" $ ./bump-version.sh 1.2.1 Files modified successfully, version bumped to 1.2.1. $ git commit -a -m "Bumped version number to 1.2.1" [hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1 1 files changed, 1 insertions(+), 1 deletions(-)

Don’t forget to bump the version number after branching off!

Then, fix the bug and commit the fix in one or more separate commits.

$ git commit -m "Fixed severe production problem" [hotfix-1.2.1 abbe5d6] Fixed severe production problem 5 files changed, 32 insertions(+), 17 deletions(-)

Finishing a hotfix branch

When finished, the bugfix needs to be merged back into master, but also needs to be merged back into develop, in order to safeguard that the bugfix is included in the next release as well. This is completely similar to how release branches are finished.

First, update master and tag the release.

$ git checkout master Switched to branch 'master' $ git merge --no-ff hotfix-1.2.1 Merge made by recursive. (Summary of changes) $ git tag -a 1.2.1

Edit: You might as well want to use the -s or -u <key> flags to sign your tag cryptographically.

Next, include the bugfix in develop, too:

$ git checkout develop Switched to branch 'develop' $ git merge --no-ff hotfix-1.2.1 Merge made by recursive. (Summary of changes)

The one exception to the rule here is that, when a release branch currently exists, the hotfix changes need to be merged into that release branch, instead ofdevelop. Back-merging the bugfix into the release branch will eventually result in the bugfix being merged into develop too, when the release branch is finished. (If work indevelop immediately requires this bugfix and cannot wait for the release branch to be finished, you may safely merge the bugfix into develop now already as well.)

Finally, remove the temporary branch:

$ git branch -d hotfix-1.2.1 Deleted branch hotfix-1.2.1 (was abbe5d6).

Summary

While there is nothing really shocking new to this branching model, the “big picture” figure that this post began with has turned out to be tremendously useful in our projects. It forms an elegant mental model that is easy to comprehend and allows team members to develop a shared understanding of the branching and releasing processes.

A high-quality PDF version of the figure is provided here. Go ahead and hang it on the wall for quick reference at any time.

Update: And for anyone who requested it: here’s the gitflow-model.src.key of the main diagram image (Apple Keynote).

Tagged : / / / / / / / / / / / / / / /

Work on remote Subversion repositories locally with Git

remote-subversion-git

Work on remote Subversion repositories locally with Git

Version control is great stuff, and being able to combine different version control mechanisms is even better. Subversion is a very popular version control system and a lot of repositories (public or otherwise) use Subversion to manage files. Git is another popular one, but what happens if you are working on a project where Subversion is used but Git is your preferred version control system?

With the git-svn plugin, you can have the best of both worlds. You can convert a Subversion repository to Git, use Git tools, then push the changes back to Subversion.

To begin, you will need the git-svn plugin installed. Most likely, if your distribution of choice provides Git, it will also provide git-svn. On Fedora, install it using:

# yum install git-svn

Then use git-svn to check out your Subversion repository into Git format:

% mkdir -p ~/git/code

$ cd ~/git/code

% git svn init http://svn.host.com/svn/code

Initialized empty Git repository in /home/user/git/code/.git/

% git svn fetch

This may take a while on large repositories

r267 = 079b7c1cff49187d1aabc4b16f316102088fdc0d (refs/remotes/git-svn)

W: +empty_dir: trunk

r268 = 3f1944530a092c811c55720bd9322b8c150a535b (refs/remotes/git-svn)

r351 = e2af3c12e5ed174d23ffc5917f03a6136f8ebb6b (refs/remotes/git-svn)

Checked out HEAD:

http://svn.host.com/svn/code r351

At this point, the Subversion repository located at http://svn.host.com/svn/code has now been checked out in Git format. On individual files and directories, you can use the git log command as you would the svn log command in order to get history information on the item in question. With git, you will also see the Subversion commit that corresponds to the log entry, for instance:

commit 23f705cd87e1e9c6dd841ca88a14d808e0c4292a

Author: user@HOST.COM

Date:   Sat Mar 20 18:25:38 2010 +0000

correct logic on the buildrequires extractor, add stats on BuildRequires to showdbstats output

git-svn-id: http://svn.host.com/svn/code@350 7a5473d1-2304-0410-9229-96f37a904fa4

With the above, you can see that user@HOST.COM did the commit, see the log message, and the Subversion revision (r350).

To work with these files, make changes as normal. git diff works like svn diff does, to see the changes made. To commit changes, use git commit like you would use svn:

% git commit -m “some minor change” file

[master 2454be1] some minor change

1 files changed, 2 insertions(+), 0 deletions(-)

To update your local copy from Subversion, instead of using svn update use git svn rebase. This will merge in any changes found in the Subversion repository.

When committing files using git commit, you are committing your changes to the Git repository. None of these changes are pushed to the Subversion repository until you specifically tell Git to do so. This is done with the git svn dcommit command, which then takes each commit made to Git and pushes them to Subversion as individual commits, which will retain all of your history and log comments:

% git svn dcommit

Committing to http://svn.host.com/svn/code …

M      trunk/rqp

Committed r352

M      trunk/rqp

r352 = 0557314a580c4390ff646380baa3aa33d1f6a5cd (refs/remotes/git-svn)

No changes between current HEAD and refs/remotes/git-svn

Resetting to the latest refs/remotes/git-svn

Unstaged changes after reset:

M      trunk/rqp

M      trunk/rqp

Committed r353

M      trunk/rqp

r353 = 249e97283ad28126bf84ccaffb32873e12d15b7b (refs/remotes/git-svn)

No changes between current HEAD and refs/remotes/git-svn

Resetting to the latest refs/remotes/git-svn

Now, if you were to look at the changed file(s) in Subversion (via another Subversion working copy or something like ViewVC), you will see the individual commits. Above, there were two changes made to the trunk/rqp file, each committed locally to Git. The “dcommit” command pushed those changes as individual commits to the Subversion repository. In this way you can do all local development with Git and when you have something you want to commit to the Subversion repository, you can push all of the relevant changes at once, retaining each separate commit.

Using the git-svn plugin makes it extremely easy to use Git locally with a remote Subversion repository. If you are in a project or organization that, for whatever reason, does not want to convert to Git, you can continue to work with that Subversion repository, without the restriction of using Subversion yourself.

Tagged : / / / / / / / / / / / / / / / / / / /