Laurent Menut - GIT commands
Initialize repositories
- Create your remote repository from the root (= trunk) repository
|
git clone --bare newcalcul:/ws3/pollux/CHIMERE/chimereRoot/ /data/PLT6/pub/user/MyChimereGit
|
- create your local repository from your remote one on /data/PLT6/pub; its name will be chimere
ssh chims-n2
cd mychimere
git clone /data/PLT6/pub/user/MyChimereGit chimere
|
- to follow the trunk repository (= to be able to synchronize with it)
cd chimere
git remote add -f trunk newcalcul:/ws3/pollux/CHIMERE/chimereRoot/
gitk --all &
|
Develop, commit and submit your changes
- create your branch for specific developments
|
git checkout -b my_branch
|
- switch between branches
|
git checkout another_branch
|
- Check if actions are pending
git status
git status -uno (to see followed files only)
|
- develop and update your own local branches
git add routine_names
git commit (and document your changes in the text file)
gitk --all
|
- to see what's going on in remote repositories (those added with the "git remote add" command)
- get the new developments from the trunk to your master branch and resolve conflicts if there
git checkout master
git pull trunk master
|
- get developments from your local my_branch branch to your local master branch
or
git cherry-pick (SHA-1 modif 1)
.....
git cherry-pick (SHA-1 modif N)
|
- Put those changes to your remote repository
- Move your development branch directly to the devel branch (SHA-1)
git reset --hard (SHA-1)
git push -f origin my_branch
- Rename a local branch:
git branch -m [new_name]
- Delete a local branch:
git branch -d [to_delete]
- Delete a remote branch:
git push [remote_name] --delete [branch_name]
- Put your devel branch to the depot_root level. Move your changes from your local working branch my_work to your local devel branch.
git checkout devel
git pull depot_root/devel
git checkout
git rebase devel
then resolve conflicts
git rebase --continue
Use kdiff3 for differences between branches
- Create an executable script file named ~/scripts/git-diff-wrapper.sh
- Put in the script the following code:
#!/bin/sh
# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode
"/usr/bin/kdiff3" "$2" "$5" | cat
|
- Add this line in your GIT config file, named ~/.gitconfig
[diff]
external = ~/scripts/git-diff-wrapper.sh
|
- You can now see differences between two branches, for all routines in a directory with the command line:
GIT page Romain Pennel