GIT : Pushing a commit into a branch
This information is for Scilab developers and code contributors. See GIT for a table of content on Git usage. If you are a user of Scilab, you probably don't need to look at this.
This page details a process to commit a change into a particular branch of Scilab. Here, we choose to commit into the master branch. Because of the Git/Gerrit combination, there is a slight change with respect to the regular combination.
Contents
Summary of the process
We make the assumption that we already are on the master branch.
Here is a summary.
1. Create the commit
git add myfile.txt git commit -m "modulename: Bug #XXXX: increased accuracy of some function"
2. Get the updates, push the commit
git fetch git rebase origin/master master
or simply
git pull
then push to gerrit for review:
git push origin master:refs/for/master
if you were to commit to another branch (e.g. the 5.5 branch), you would run:
git fetch git rebase origin/5.5 5.5 git push origin 5.5:refs/for/5.5
3. Getting clean back again
git fetch git reset --hard remotes/origin/master
Create the commit
example on atoher branch (5.3):
myname@mymachine /git-scilab/scilab/scilab/modules (5.3) $ git status # On branch 5.3 # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: ../CHANGES_5.3.X # modified: development_tools/macros/test_run.sci # no changes added to commit (use "git add" and/or "git commit -a") myname@mymachine /git-scilab/scilab/scilab/modules (5.3) $ git add ../CHANGES_5.3.X development_tools/macros/test_run.sci myname@mymachine /git-scilab/scilab/scilab/modules (5.3) $ git commit -m "devtools: test_run did not work with modules starting with letter n" [5.3 ba1ff4b] devtools: test_run did not work with modules starting with letter n 2 files changed, 66 insertions(+), 10 deletions(-)
Get the updates, push the commit
myname@mymachine /git-scilab/scilab/scilab/modules (5.3) $ git fetch remote: Counting objects: 30299, done remote: Compressing objects: 100% (128/128) Receiving objects: 100% (128/128), 28.01 KiB, done. Resolving deltas: 100% (102/102), completed with 31 local objects. From ssh://git.scilab.org:29418/scilab 07bbd6e..3c2c10f 5.3 -> origin/5.3 myname@mymachine /git-scilab/scilab/scilab/modules (5.3) $ git rebase origin/5.3 5.3 First, rewinding head to replay your work on top of it... Applying: devtools: test_run did not work with modules starting with letter n myname@mymachine /git-scilab/scilab/scilab/modules (5.3) $ git push origin 5.3:refs/for/5.3 Counting objects: 15, done. Delta compression using up to 4 threads. Compressing objects: 100% (8/8), done. Writing objects: 100% (8/8), 1.37 KiB, done. Total 8 (delta 7), reused 0 (delta 0) remote: (W) 0522fa: commit subject >65 characters; use shorter first paragraph remote: remote: New Changes: remote: http://codereview.scilab.org/2131 remote: To ssh://michael.myname@git.scilab.org:29418/scilab * [new branch] 5.3 -> refs/for/5.3
Getting clean back again
myname@mymachine /git-scilab/scilab/scilab/modules (5.3) $ git fetch remote: Counting objects: 31421, done remote: Compressing objects: 100% (28/28) Unpacking objects: 100% (28/28), done. From ssh://git.scilab.org:29418/scilab 2d0986b..32279e2 5.3 -> origin/5.3 8d4d4f8..302637d m2sci -> origin/m2sci dad5833..ba7e047 uicontrol -> origin/uicontrol myname@mymachine /git-scilab/scilab/scilab/modules (5.3) $ git reset --hard remotes/origin/5.3 HEAD is now at 32279e2 added const modifiers to parameters of create*SparseMatrixIn*List() myname@mymachine /git-scilab/scilab/scilab/modules (5.3) $ git status # On branch 5.3 nothing to commit (working directory clean)