[zypp-devel] git example usage, committing to a maintenance branch
NOTE: Before doing any push, make sure the git identity is set correctly to your email address. git config --global user.name "Your Name Comes Here" git config --global user.email you@yourdomain.example.com (If you don't use --global the config is for that checkout only, the default is your login@host, so please make sure it is set) Note, this is a step by step on how to commit a change to a branch without having a separate I checked out sat solver. So I list branches: # sat-solver> git branch -a * master origin/HEAD origin/SuSE-Linux-11_0-Branch origin/master The -a option tells git to list also remote branches. The default remote is origin, which is the one from which we checked out. One can have multiple remotes in parallel (for example push & backup to github.com). Remote branches don't exist in our repo. We checkout the remote branch in a local branch. We use checkout -b LB RB, which is the same as git branch RB LB and then git checkout LB. # sat-solver> git checkout -b 11_0 origin/SuSE-Linux-11_0-Branch Branch 11_0 set up to track remote branch refs/remotes/origin/SuSE-Linux-11_0-Branch. Switched to a new branch "11_0" # sat-solver> Now there are two local branches. The * indicates which one is the checkout copy (the workspace). # sat-solver> git branch * 11_0 master If you examine the git config, you can see the branch was added there, and by default it tracks the remote branch, that means if you pull from the remote (git pull) without specifying more parameters, if you are standing in the local 11_0 branch it will look for commits in the remote origin/SuSE-Linux-11_0-Branch cat .git/config [branch "11_0"] remote = origin merge = refs/heads/SuSE-Linux-11_0-Branch Then I edit some file: # sat-solver/package> vi libsatsolver.changes Or, alternatively, if you are more cool: # sat-solver/package> emacs libsatsolver.changes Then, you have to add that change to the index, which is what git takes in consideration for commit: # sat-solver/package> git add libsatsolver.changes # sat-solver/package> git commit -m "update changelog" You can skip that step by using git commit -a -m "msg" which commits every change. The index is useful because you can have multiple changes in the workspace and you can commit only some of them. You can even commit part of the changes in a file and some not by using git-add-interactive (I am not sure if that is the right command, something like that). Then I made my first mistake, I pushed: # sat-solver> git push Everything up-to-date And I expected that git would figure out where to push from the added "merge" line in config. It seems you have to add a push: line in config too, or specify it: (I am sure there is an easier way here ;-) ) # sat-solver> git push origin 11_0:SuSE-Linux-11_0-Branch Counting objects: 7, done. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 522 bytes, done. Total 4 (delta 2), reused 0 (delta 0) To git@git.opensuse.org:projects/zypp/sat-solver.git 9ac4503..9cda046 11_0 -> SuSE-Linux-11_0-Branch Duncan -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (1)
-
Duncan Mac-Vicar Prett