Git Notes

Version 15 by Stephane Carrez

Update Git repo with submodules

 git pull
 git submodule init
 git submodule update --recursive

Eventuellement

 git submodule update --init --recursive

Push local tags on master

 git push <tag-name>

Migrate SVN to Git on private server

Create Git repository on server:

mkdir /home/git/project.git
cd /home/git/project.git
git init --bare

Make a local Git workspace and import the SVN repository with full history:

mkdir $HOME/project
cd $HOME/project
git svn clone svn://repo

Change Git master:

git remote add origin /home/git/project.git

Push files to the Git repository:

git push -u origin master

Change Origin

git remote set-url origin git@github.com:stcarrez/ada-awa.git

Erase local changes and drop commits

Drops the local commits:

git reset --hard origin/master

Configure user name per repository

 git config user.email Stephane.Carrez@xxx.yyy
 git config user.name 'Stephane Carrez'

Synchronize a GitHub fork

 git remote add upstream https://github.com/xxx
 git fetch upstream
 git checkout master
 git merge upstream/master

Move submodule

 git submodule set-url -- ada-util https://gitlab.com/stcarrez/ada-util.git
 git submodule set-url -- ada-el https://gitlab.com/stcarrez/ada-el.git

Merge conflicts

Resolve a sub-module merge conflict (on my resource-embedder project). After a merge from master to a branch, a conflict on `ada-util` submodule is solved by:

 git checkout master ada-util

Change submodule branch

 git config -f .gitmodules submodule.<submodule>.branch <branch>

Update submodules

 git submodule update --remote --recursive