Difference between revisions of "Yade on github"

From Yade

 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  +
'''Despite the fact that present wiki page still yet exists, better refer now to the doc page describing git / github usage [https://www.yade-dem.org/doc/github.html].'''
== Using branches on GitHub ==
 
   
Most usefull commands are below. For more details, see for instance http://gitref.org/index.html
 
   
  +
  +
  +
== Fast checkout without GitHub account (read-only) ==
  +
  +
Getting the source code in without registering on GitHub can be done via a single command. It will not allow interactions with the remote repository, which you access the read-only way:
  +
git clone https://github.com/yade/trunk.git
  +
  +
  +
 
== Using branches on GitHub ==
  +
 
Most usefull commands are below. For more details, see for instance http://gitref.org/index.html and https://help.github.com/articles/set-up-git
   
 
=== Setup ===
 
=== Setup ===
Line 8: Line 19:
 
1. Register on github.com
 
1. Register on github.com
   
2. Add your SSH key to GitHub[http://help.github.com/linux-set-up-git/]:
+
2. Add your SSH key[https://help.github.com/articles/generating-ssh-keys] to GitHub[http://help.github.com/linux-set-up-git/]:
 
On the GitHub site Click “Account Settings” > Click “SSH Public Keys” > Click “Add another public key”
 
On the GitHub site Click “Account Settings” > Click “SSH Public Keys” > Click “Add another public key”
   
Line 25: Line 36:
 
git remote add upstream git@github.com:yade/trunk.git
 
git remote add upstream git@github.com:yade/trunk.git
 
git fetch upstream
 
git fetch upstream
  +
  +
=== Retrieving older Commits ===
  +
In case you want to work with or compile an older version of Yade which is not tagged, you can create your own (local) branch of the corresponding daily build. Look at [https://answers.launchpad.net/yade/+question/235867] for details.
   
 
=== Committing and updating (for frequent commits see git/trunk section) ===
 
=== Committing and updating (for frequent commits see git/trunk section) ===
Line 43: Line 57:
 
git add path/to/new/file.cpp #Version a newly created file (equivalent of "bzr add"), or
 
git add path/to/new/file.cpp #Version a newly created file (equivalent of "bzr add"), or
 
git commit path/to/new_or_modified/file.cpp -m'Commit message' #Validate a change. It can be done several times after every sufficient change (no equivalent in bzr, it's like commiting to your own local repository), or
 
git commit path/to/new_or_modified/file.cpp -m'Commit message' #Validate a change. It can be done several times after every sufficient change (no equivalent in bzr, it's like commiting to your own local repository), or
git push #Push your changes into gitHub (equivalent of "bzr commit", except that your are commiting to your own remote branch)
+
git push #Push your changes into GitHub (equivalent of "bzr commit", except that your are commiting to your own remote branch)
   
 
Changes will be pushed to your personal "fork", If you have tested your changes and you are ready
 
Changes will be pushed to your personal "fork", If you have tested your changes and you are ready
to push them into the main trunk, just do a "pull request" [http://help.github.com/send-pull-requests/]. After reviewing your changes they will be added to the main trunk.
+
to push them into the main trunk, just do a "pull request" [http://help.github.com/send-pull-requests/] or create a patch from your commit via
  +
git format-patch origin #create patch file in current folder
  +
and send to the developers maililng list (yade-dev@lists.launchpad.net) as attachment.
  +
In either way, after reviewing your changes they will be added to the main trunk.
   
 
When the pull request has been reviewed and accepted, your changes are integrated in the main trunk. Everyone will get them via "git fetch".
 
When the pull request has been reviewed and accepted, your changes are integrated in the main trunk. Everyone will get them via "git fetch".
Line 59: Line 76:
   
 
git pull
 
git pull
 
   
 
== Working directly on git/trunk (recommended for frequent commits) ==
 
== Working directly on git/trunk (recommended for frequent commits) ==
Line 78: Line 94:
   
 
To avoid confusing logs after each commit/pull/push cycle, it is convenient to setup [http://www.stevenharman.net/git-pull-with-automatic-rebase automatic rebase]:
 
To avoid confusing logs after each commit/pull/push cycle, it is convenient to setup [http://www.stevenharman.net/git-pull-with-automatic-rebase automatic rebase]:
git config branch.autosetuprebase always
+
git config --global branch.autosetuprebase always
  +
To be sure that git is setup correctly check ~/.gitconfig:
  +
[branch]
  +
autosetuprebase = always
  +
Check also .git/config file in your local trunk folder (rebase = true):
  +
[branch "master"]
  +
remote = origin
  +
merge = refs/heads/master
  +
rebase = true
   
 
Auto-rebase may have unpleasant side effects by blocking "pull" if you have uncommited change. In this case you can use "git stash":
 
Auto-rebase may have unpleasant side effects by blocking "pull" if you have uncommited change. In this case you can use "git stash":
Line 88: Line 112:
 
git pull #now it's ok
 
git pull #now it's ok
 
git push #push the commited changes
 
git push #push the commited changes
git stash apply #get uncommited changes back
+
git stash pop #get uncommited changes back
  +
  +
=== General guidelines for pushing to yade/trunk ===
  +
#set autorebase once on the computer! (see above)
  +
#inspect the diff to make sure you will not commit junk code (typically some "cout<<" left here and there):
  +
#:* git diff file1
  +
#:or alternatively, any GUI for git:
  +
#:*gitg
  +
#:*git-cola
  +
#:*...
  +
#commit selectively:
  +
#:*git commit file1 file2 file3 -m "message" <--- good
  +
#:*git commit -a -m "message" <---- bad, best way to commit things that should not be commited
  +
#git pull
  +
#make sure it compiles
  +
#try "yade --test"
  +
#try "yade --check"
  +
#git push

Latest revision as of 16:36, 21 August 2014

Despite the fact that present wiki page still yet exists, better refer now to the doc page describing git / github usage [1].



Fast checkout without GitHub account (read-only)

Getting the source code in without registering on GitHub can be done via a single command. It will not allow interactions with the remote repository, which you access the read-only way:

  git clone https://github.com/yade/trunk.git


Using branches on GitHub

Most usefull commands are below. For more details, see for instance http://gitref.org/index.html and https://help.github.com/articles/set-up-git

Setup

1. Register on github.com

2. Add your SSH key[2] to GitHub[3]:

 On the GitHub site Click “Account Settings” > Click “SSH Public Keys” > Click “Add another public key”

3. Set your username and email:

 git config --global user.name "Firstname Lastname"
 git config --global user.email "your_email@youremail.com"

4. Fork A Repo[4]:

 click the “Fork” button on the https://github.com/yade/trunk

5. Set Up Your Local Repo:

 git clone git@github.com:username/trunk.git
 

6. Configure remotes:

 cd to/newly/created/folder
 git remote add upstream git@github.com:yade/trunk.git
 git fetch upstream

Retrieving older Commits

In case you want to work with or compile an older version of Yade which is not tagged, you can create your own (local) branch of the corresponding daily build. Look at [5] for details.

Committing and updating (for frequent commits see git/trunk section)

Note for bazaar users: the commit mechanisms in Git significantly differs from that of Bazaar or SVN. Therefore, don't expect to find a one-to-one command replacement. In some cases, however, the equivalent bazaar command is indicated below to ease the transition.

Inspecting changes

You may start by inspecting your changes with a few commands. For the "diff" command, it is convenient to copy from the output of "status" instead of typing the path to modified files.

git status
git diff path/to/modified/file.cpp

Committing changes

Then you proceed to commit:

git add path/to/new/file.cpp   #Version a newly created file (equivalent of "bzr add"), or
git commit path/to/new_or_modified/file.cpp -m'Commit message'      #Validate a change. It can be done several times after every sufficient change (no equivalent in bzr, it's like commiting to your own local repository), or
git push                            #Push your changes into GitHub (equivalent of "bzr commit", except that your are commiting to your own remote branch)

Changes will be pushed to your personal "fork", If you have tested your changes and you are ready to push them into the main trunk, just do a "pull request" [6] or create a patch from your commit via

git format-patch origin #create patch file in current folder

and send to the developers maililng list (yade-dev@lists.launchpad.net) as attachment. In either way, after reviewing your changes they will be added to the main trunk.

When the pull request has been reviewed and accepted, your changes are integrated in the main trunk. Everyone will get them via "git fetch".

Updating

You may want to get changes done by others:

git fetch upstream                          #Pull new updates from the upstream to your branch (eq. of "bzr update", updating the remote branch from the upstream yade/trunk) 
git merge upstream/master                   #Merge upstream changes into your master-branch (eq. of "bzr update", updating your local repository from the remote branch)

Alternatively, this will do fetch+merge all at once (discouraged if you have uncommited changes):

git pull

Working directly on git/trunk (recommended for frequent commits)

This direct access to trunk will sound more familiar to bzr or svn users. It is only possible for members of the git team "developpers". Send an email at yade-dev@lists.launchpad.net to join this team (don't forget to tell your git account name).

Get trunk:

 git clone git@github.com:yade/trunk.git

Update:

 git pull

Commit to local repository:

 git commit filename1 filename2 ...

Push changes to remote trunk:

 git push

To avoid confusing logs after each commit/pull/push cycle, it is convenient to setup automatic rebase:

 git config --global branch.autosetuprebase always

To be sure that git is setup correctly check ~/.gitconfig:

 [branch]
   autosetuprebase = always

Check also .git/config file in your local trunk folder (rebase = true):

 [branch "master"]
   remote = origin
   merge = refs/heads/master
   rebase = true

Auto-rebase may have unpleasant side effects by blocking "pull" if you have uncommited change. In this case you can use "git stash":

 git pull
 lib/SConscript: needs update
 refusing to pull with rebase: your working tree is not up-to-date
 git stash #hide the uncommited changes away
 git pull  #now it's ok
 git push  #push the commited changes
 git stash pop #get uncommited changes back

General guidelines for pushing to yade/trunk

  1. set autorebase once on the computer! (see above)
  2. inspect the diff to make sure you will not commit junk code (typically some "cout<<" left here and there):
    • git diff file1
    or alternatively, any GUI for git:
    • gitg
    • git-cola
    • ...
  3. commit selectively:
    • git commit file1 file2 file3 -m "message" <--- good
    • git commit -a -m "message" <---- bad, best way to commit things that should not be commited
  4. git pull
  5. make sure it compiles
  6. try "yade --test"
  7. try "yade --check"
  8. git push