GIT: Difference between revisions

From hugovil.com
Jump to navigationJump to search
Line 33: Line 33:
= Conversion SVN à GIT =
= Conversion SVN à GIT =


== Cloner le répertoire SVN ==
Cloner le répertoire SVN:


   $> git svn clone --stdlayout --no-metadata \
   $> git svn clone --stdlayout --no-metadata -A ~/projets/vcs/svn-to-git-migration/users.txt https://subversion.assembla.com/svn/gbjazz/ gbjazz
    -A ~/projets/vcs/svn-to-git-migration/users.txt \
    https://subversion.assembla.com/svn/gbjazz/ gbjazz


# If you want to keep other remote branches in your repo, you want to create a
If you want to keep other remote branches in your repo, you want to create a local branch for each one manually. If you don't do this, the branches won't
# local branch for each one manually. If you don't do this, the branches won't
get cloned in the final step
# get cloned in the final step.
git checkout -b local_branch remote_branch


# Tags are imported as branches. You have to create a local branch, make a tag
  $> git checkout -b local_branch remote_branch
# and delete the branch to have them as tags in git. To do it with tag "v1":
git checkout -b tag_v1 remotes/tags/v1
git checkout master
git tag v1 tag_v1
git branch -D tag_v1


# Clone your GIT-SVN repo into a clean git repo:
Tags are imported as branches. You have to create a local branch, make a tag and delete the branch to have them as tags in git. To do it with tag "v1":
git clone dest_dir-tmp dest_dir
rm -rf dest_dir-tmp
cd dest_dir


# The local branches that you created earlier from remote branches will only
  $> git checkout -b tag_v1 remotes/tags/v1
# have been copied as remote branches into the new cloned repository. For each
  $> git checkout master
# branch you want to keep:
  $> git tag v1 tag_v1
git checkout -b local_branch origin/remote_branch
  $> git branch -D tag_v1


# Finally, remove the remote from your clean git repo that points to the now
# deleted temp repo:
git remote rm origin


# Push changes to new remote repository (example Assembla)
Clone your GIT-SVN repo into a clean git repo:
git remote add origin git@git.assembla.com:gbjazz.git
git checkout master
git push --tags
git push origin master
git checkout branch1
git push origin branch1
...


# When cloning and to track remote branch:
  $> git clone dest_dir-tmp dest_dir
  $> rm -rf dest_dir-tmp
  $> cd dest_dir


$> git branch -a
The local branches that you created earlier from remote branches will only have been copied as remote branches into the new cloned repository. For each
branch you want to keep:
 
  $> git checkout -b local_branch origin/remote_branch
 
Finally, remove the remote from your clean git repo that points to the now deleted temp repo:
 
  $> git remote rm origin
 
Push changes to new remote repository (example Assembla)
  $> git remote add origin git@git.assembla.com:gbjazz.git
  $> git checkout master
  $> git push --tags
  $> git push origin master
  $> git checkout branch1
  $> git push origin branch1
  $> ...
 
When cloning and to track remote branch:
 
  $> git branch -a
* master
* master
   remotes/origin/HEAD -> origin/master
   remotes/origin/HEAD -> origin/master
Line 82: Line 82:
   remotes/origin/section-nouvelles
   remotes/origin/section-nouvelles


$> git checkout -b section-nouvelles origin/section-nouvelles
  $> git checkout -b section-nouvelles origin/section-nouvelles
Branch section-nouvelles set up to track remote branch section-nouvelles from origin.
Branch section-nouvelles set up to track remote branch section-nouvelles from origin.
Switched to a new branch 'section-nouvelles'
Switched to a new branch 'section-nouvelles'

Revision as of 04:25, 19 February 2013

Branches

Ce script peut-être utile pour créér une branche locale, l'enregistrer sur le serveur remote et ensuite la faire suivre (track):

#!/bin/bash
# git-create-branch <branch_name>

if [ $# -ne 1 ]; then
    echo 1>&2 Usage: $0 branch_name
    exit 1
fi

branch_name=$1

git checkout -b ${branch_name}
git push origin ${branch_name}
git branch --set-upstream ${branch_name} origin/${branch_name}

Pour effacer la branche distance (remote):

 $> git push origin :${branch_name}

Appliquer des patches récalcitrantes

 $> git am -3 --ignore-whitespace <name.patch>

Changer le nom de l'auteur dans un commit

 $> exec git commit --amend --author="Prénom Nom <prenom.nom@hugovil.com>" -C HEAD

Conversion SVN à GIT

Cloner le répertoire SVN:

 $> git svn clone --stdlayout --no-metadata -A ~/projets/vcs/svn-to-git-migration/users.txt https://subversion.assembla.com/svn/gbjazz/ gbjazz

If you want to keep other remote branches in your repo, you want to create a local branch for each one manually. If you don't do this, the branches won't get cloned in the final step

 $> git checkout -b local_branch remote_branch

Tags are imported as branches. You have to create a local branch, make a tag and delete the branch to have them as tags in git. To do it with tag "v1":

 $> git checkout -b tag_v1 remotes/tags/v1
 $> git checkout master
 $> git tag v1 tag_v1
 $> git branch -D tag_v1


Clone your GIT-SVN repo into a clean git repo:

 $> git clone dest_dir-tmp dest_dir
 $> rm -rf dest_dir-tmp
 $> cd dest_dir

The local branches that you created earlier from remote branches will only have been copied as remote branches into the new cloned repository. For each branch you want to keep:

 $> git checkout -b local_branch origin/remote_branch

Finally, remove the remote from your clean git repo that points to the now deleted temp repo:

 $> git remote rm origin

Push changes to new remote repository (example Assembla)

 $> git remote add origin git@git.assembla.com:gbjazz.git
 $> git checkout master
 $> git push --tags
 $> git push origin master
 $> git checkout branch1
 $> git push origin branch1
 $> ...

When cloning and to track remote branch:

 $> git branch -a
  • master
 remotes/origin/HEAD -> origin/master
 remotes/origin/master
 remotes/origin/section-nouvelles
 $> git checkout -b section-nouvelles origin/section-nouvelles

Branch section-nouvelles set up to track remote branch section-nouvelles from origin. Switched to a new branch 'section-nouvelles'