Wednesday, 10 May 2017

GIT, contributing, config, fork, push, pull-request, export ...

Branching, Rebasing, Picking and Pushing to repository

Interactive rebasing, to merge file-by-file an specific branch before pushing (DONT DO IT ON REMOTES)
    git rebase -i <parent-branch>

Cherry picking: just copy a single commit from other branch
    git cherry-pick -e -x <original-commit>

Push: Once your local commits have been cleanly reapplied you can push your changes to the central repository:
    git push origin master:master

Create/Remove local branches
    git branch development
    git checkout development #switching to new branch
    git checkout master #going back
    git branch -d development #deleting

Creating a new local branch that tracks a remote branch
    git branch --track <local-branch> <remote-branch>
    git checkout <local-branch>

Change the upstream branch tracked by the local branch:
    git branch --set-upstream-to <new-upstream-branch>
    #git branch --set-upstream <existing-branch> <new-upstream-branch>

Creating a new remote branch and pushing local commits:
    git push origin <local-branch>:<remote-branch>

Deleting a local branch
    git checkout master #Change into another branch
    git branch -d <local-branch>

Deleting a remote branch, cuidao!!!
    git push origin :<remote-branch>

merging your branch against master; In case of conflict Git will not commit the merge and will add conflict markers to the files
    $ git checkout master
    $ git merge your_local_branch


Git: exporting the contents of master as a "clean dist"

This code will produce a clean directory with all the source but without .git folder:
  pydatabaseds>mkdir ../export
  pydatabaseds> git archive master | tar -x -C ../export/

Pull-Requests

Use rebase only with un-pushed code; do not use it with published code as it will mess up the history!!

Then, doing the interactive merging to add the code:
rebase -i HEAD~15
The number after HEAD is the number of commits to go back. BE CAREFUL WITH THIS AND PUT ONLY THE EXACT NUMBER OF COMMITS YOU HAVE PENDING
In case of error, you can resume the ongoing merge:
rebase --continue

Create and send patch to Sardana


The steps are rebasing, solve conflicts, format-patch and send-email

#BE VERY CAREFULT WITH THAT THING ... MAYBE IS NOT NEEDED!!
git rebase -i origin/develop 

kwrite file_with_conflicts.py
add file_with_conflicts.py
git rebase --continue
git format-patch -M origin/develop
less 0006-solved-bug-when-pixmap-is-not-set.patch

#Send email must be properly configured!
     git config --global core.editor "vim"  #avoid broken merge because of empty editor
git config user.name ...
git config user.email ...
git config sendemail.smtpserver ...
git config sendemail.to sardana-devel@lists.sourceforge.net
git config sendemail.from ...
git config sendemail.confirm always

git send-email --cc=... --cc=... *.patch

Notes from my own branch merging into Taurus (2014/02/10)

Put my own changes "in the fridge":
git stash
Recover the files "from the fridge":
git stash pop
Update my develop branch to sourceforge (be careful!)
git remote update
git checkout develop
git pull origin develop
git checkout dragging_bug #Back to my own branch
git rebase develop #Reapply changes done in develop to my branch?

No comments:

Post a Comment