Skip to content

Instantly share code, notes, and snippets.

@julian-garrido
Created May 30, 2014 08:50
Show Gist options
  • Save julian-garrido/f5f025b2420a5990cba0 to your computer and use it in GitHub Desktop.
Save julian-garrido/f5f025b2420a5990cba0 to your computer and use it in GitHub Desktop.
GIT and maven commands
BASIC
————————————————————————————————————
SETP UP GIT
http://help.github.com/linux-set-up-git/
cd ~/.ssh
ssh-keygen -t rsa -C "jgarrido@*****"
PASSPHRSASE: *******
add key to github:
ssh-rsa ****** jgarrido@****
edit ~/.profile (http://help.github.com/ssh-key-passphrases/)
A commit is essentially a snapshot of all the files in your project at a particular point in time. In the prompt, type the following code:
$ git add README
$ git commit -m 'first commit'
To connect your local repository to your GitHub account, you will need to set a remote for your repo and push your commits to it:
$ git remote add origin git@github.com:username/Hello-World.git
$ git push -u origin master
COMMON COMMANDS
cd ~/git
creates a .git folder in ~/git
git init
cd ~/git/repository
follow this instructions: http://help.github.com/fork-a-repo/
Import project
git clone git@github.com:wf4ever/astrotaverna.git on the command line ---> it creates a folder named astrotaverna
Configure remotes
git remote add upstream git://github.com/wf4ever/astrotaverna.git
git fetch upstream
Bring a branch (gh-pages) from remote:
git branch -a
git fetch origin
git checkout -b gh-pages origin/gh-pages
git branch
To switch between branches:
git checkout master
git checkout gh-pages
To commit
git commit -m "Name of the commit"
To see the statuts
git status
if changes in remote project
git pull
$ git push -u upstream master
Push commits:
git push origin master
Add a new document to git and commit (in your local pc):
$ git add README
$ git commit -m 'first commit'
To upload changes
$ git remote add origin git@github.com:username/Hello-World.git
$ git push -u upstream master
$ git push -u origin master
git pull
https://github.com/wf4ever/astrotaverna
http://wf4ever.github.com/astrotaverna/
git://github.com/wf4ever/astrotaverna.git
Example:
$ git remote add origin git@github.com:username/Hello-World.git
$ git push -u origin master
BRANCHING - git
create a new branch
git branch testing
move to another brach
git checkout testing
create and move to a new branch
git checkout -b iss53
see the existing branches
git branch
delete a brach
git branch -d testbranch
merge pdl branch into master, los cambios de pdl se meten en master
git checkout master
git merge pdl
See differences between two branches:
git diff --stat --color 0.9estable..master
See the branches that have or haven't been merged
git branch --merged
git branch --no-merged
Rename a branch
git branch -m old_branch new_branch
Delete a branch
git branch -d testing
to see all the branches that are hide
git branch -a
create and move to a new branch,
and push this branch to github
set tranking information for this branch (I guess this can be done in one step by using --track, but not sure about this)
git checkout -b dev
git push origin dev
git branch --set-upstream-to=origin/dev
This tells gt to push changes from you interop. branch to the interop. bran on the origin repository. if origin doesn't have a interop. branch, it is created on the fly. The -u tells git that you want to be able to easily push and pull changes to that branch in the future.
git push -u origin interoperability
if you bring the branch from the server, the tracking is enabled by
git checkout -b dev origin/dev
Bring a branch from a server and see the list of branches
git remote show origin
git checkout -b utilities-thread-safeRFC origin/utilities-thread-saveRFC
ADDITIONAL COMMANDS AND OPTIONS
————————————————————————————————————————————
DESCARTAR CAMBIOS
Para descartar cambios y volver a commits anteriores
http://gitevangelism.blogspot.com.es/2010/12/descartar-todos-los-cambios-no.html
It deletes all removed files, updates what was modified, and adds new files.
git add -u
git remove files which have been deleted
git rm $(git ls-files --deleted)
git rm `git ls-files --deleted`
discard changes for uncommitted file.
git checkout -- pom.xml
remove untracked files and directories
git clean -fd
TRABAJAR CON VARIOS RESPOSITORIOS
—————————————————————————————————
to clone a remote repository (you only see the master branch):
git clone git@github.com:wf4ever/vo-param.git
If you just want to take a quick peek at an upstream branch, you can check it out directly:
git checkout origin/experimental
But if you want to work on that branch, you'll need to create a local tracking branch:
git checkout -b experimental origin/experimental
git checkout -b utilities-thread-safe remotes/origin/utilities-thread-safe
UPDATING ASTROTAVERNA
If the original repo you forked your project from gets updated, you can add those updates to your fork by running the following code:
$ git fetch upstream
$ git merge upstream/master
TO FORK - CLONE - PULL ASTROTAVERNA
- fork wf4ever/astrotaverna project into julian-garrido user (at github webpage)
- git clone git@github.com:julian-garrido/astrotaverna.git
- When a repository is cloned, it has a default remote called origin that points to your fork on GitHub, not the original repository it was forked from. To keep track of the original repository, you need to add another remote named upstream:
- git remote add upstream https://github.com/wf4ever/astrotaverna.git
- the previous did't work and I did: git pull upstream dev --->> then remove conflicts manually
- Assigns the original repository to a remote called "upstream"
- git fetch upstream
- Pulls in changes not present in your local repository, without modifying your files
Pushes commits to your remote repository stored on GitHub
- git push origin master
Pull in upstream changes: f the original repository you forked your project from gets updated, you can add those updates to your fork by running the following code
- 1.- git fetch upstream (Fetches any new changes from the original repository)
- 2.- git merge upstream/master (Merges any changes fetched into your working files)
ó
- 2.- git merge upstream/dev (if you want to merge with the dev branch)
FORK 1 - CLONE 2 - PULL 1 - PUSH 2
[clonar mi repositorio que viene de un fork de un tercero. ]
1.- git clone git@github.com:CANUBE/astrotaverna.git
2.- cd astrotaverna
[para traer cambios del repositorio original]
3.- git remote add upstream https://github.com/wf4ever/astrotaverna.git
4.- git fetch upstream
[comparar el repositorio original con el local]
5.- git diff upstream/master master
[traer cambios del repositorio original a mi rama]
6.- git merge upstream/master
[hacer nuevos cambios]
7.- (hacer cambios y commit)
[enviar cambios a github]
7.- git push origin master
TO UPDATE VO-PARAM RESPOSITORY FROM SVN GOOGLE CODE PROJECT
Hacer un git svn clone y subirlo a github como un repositorio nuevo. Luego, configurar los remotes en github-vo-param para que pueda traerse cambios de ese repositorio. (Publicado en stackoverflow)
//Clone the svn repository using git svn and upload to github
cd src
git svn clone http://vo-param.googlecode.com/svn/trunk/model vo-param_svn
cd vo-aram_svn
git remote add origin git@github.com:julian-garrido/vo-param_svn.git
git push -u origin master
cd ..
//add a new remote into your project to fetch from vo-param_svn
cp -R vo-param_bck/ vo-param
cd vo-param
git remote add svnClone git://github.com/julian-garrido/vo-param_svn.git
git fetch svnClone
* [new branch] master -> svnClone/master
//bring remote updates to my master branch
git checkout master
git merge svnClone/master
//Now, I have the latest changes from the svn repository in my git master branch I can merge branches or cherry pick
git checkout utilities-thread-safe
git checkout -b utilities-thread-safeRFC
git merge master
Hacer un pusH a la branch que quiero en vo-param
estando en utilities-thread-safeRFC tengo que hacer:
git push -u origin utilities-thread-safeRFC
TO INSTALL SOMETHING IN THE REPOSITORY
http://help.github.com/fork-a-repo/
git clone git@github.com:wf4ever/astrotaverna.git
cd astrotaverna
git remote add upstream git://github.com/wf4ever/astrotaverna.git
git fetch upstream
--two branches (gh-pages and master)
according to STIAN:
git checkout gh-pages
git commit
git push
MAVEN AND ECLIPSE
———————————————————————————————————————————————————
mvn install skipping tests
mvn install -DskipTests
Stian Soiland-Reyes: which is http://wf4ever.github.com/astrotaverna/ - to install something there, do a git checkout gh-pages on the astrotaverna project - and then use it with mvn deploy:deploy-file
[16:25:16 CEST] Stian Soiland-Reyes: if it is not in mvnrepository.com it's pretty much not there
[16:25:36 CEST] Stian Soiland-Reyes: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html
[16:25:47 CEST] Stian Soiland-Reyes: you would have to make up groupID and version
[16:25:49 CEST] Stian Soiland-Reyes: and so on
[16:26:07 CEST] Stian Soiland-Reyes: http://maven.apache.org/plugins/maven-deploy-plugin/usage.html
[16:27:32 CEST] Stian Soiland-Reyes: for instance: (roughly) mvn deploy:deploy-file -Durl=file:///home/julian/src/astrotaverna -DrepositoryId=astrotaverna -Dfile=stilts.jar -DgroupId=package.name.used.by.stilts -DartifactId=stilts -Dversion=versionOfStilts
[16:28:07 CEST] Stian Soiland-Reyes: then if you do git commit and git push (assuming you DID checkout the gh-pages branch first!) - it should be available from the http://wf4ever.github.com/astrotaverna/ Maven repository
[16:28:22 CEST] Stian Soiland-Reyes: see https://github.com/wf4ever/astrotaverna/blob/master/pom.xml for <repository> declaration
[16:28:51 CEST] Stian Soiland-Reyes: then you can add a <dependency><groupId>sameasabove</><artifactId>..</><version>..</></>
[16:29:13 CEST] Stian Soiland-Reyes: not exactly easy, but it should work, and make it be downloaded by Taverna when you install your plugin
[16:29:27 CEST] Stian Soiland-Reyes: if you just want to mess around you can just add it to Eclipse the normal lib/ way
[16:29:34 CEST] Stian Soiland-Reyes: and then do all of this later when you know it works
[16:29:46 CEST] Stian Soiland-Reyes: if you know you have to use the stilts library, you might as well do this now
[16:30:12 CEST] Stian Soiland-Reyes: but of course, our sprint is ifnished, so if you just want to show something to Pique, then do the Eclipse build path directly!
[16:30:58 CEST] Juli√°n Garrido: ok, thank you!!
[16:32:25 CEST] Juli√°n Garrido: I guess, I will try first the direct path because I want to finish some tests today
[16:32:56 CEST] Juli√°n Garrido: But I will take all that for the next week
[16:38:23 CEST] Stian Soiland-Reyes: Note that Stilts has done a similar 'eat everything' approach to Topcat, and so might not work very well as a library
julian@ubuntu:~/git/repository/astrotaverna$ git commit -m 'first commit'
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: stilts-activity-ui/src/main/java/org/purl/wf4ever/astrotaverna/tjoin/ui/serviceprovider/StiltsServiceProvider.java
# modified: stilts-activity-ui/src/main/java/org/purl/wf4ever/astrotaverna/tjoin/ui/view/StiltsActivityContextViewFactory.java
# modified: stilts-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# stilts-activity-ui/src/main/java/org/purl/wf4ever/astrotaverna/tjoin/ui/config/SelectColumnsConfigurationPanel.java
# stilts-activity-ui/src/main/java/org/purl/wf4ever/astrotaverna/tjoin/ui/config/SelectColumnsConfigureAction.java
# stilts-activity-ui/src/main/java/org/purl/wf4ever/astrotaverna/tjoin/ui/serviceprovider/SelectColumnsServiceDesc.java
# stilts-activity-ui/src/main/java/org/purl/wf4ever/astrotaverna/tjoin/ui/view/SelectColumnsContextualView.java
# stilts-activity/src/main/java/org/purl/wf4ever/astrotaverna/tpipe/
# stilts-activity/src/test/java/org/purl/wf4ever/astrotaverna/tpipe/
no changes added to commit (use "git add" and/or "git commit -a")
[1]+ Done gedit LEEEME.txt (wd: ~/git)
(wd now: ~/git/repository/astrotaverna)
Para ver que archivos esan sin añadir
git status
Para guardar
git commint
In Eclipse. download and then file>import>existing maven project
If there are problems:
Stian Soiland-Reyes: Susana, Alternatively, right click on astrotaverna-vo-repository and do Maven -> Install, after that you can right click and close that project. you need to add target/generated-sources/somethingIdontremember to the build path - navigate to it within the astrotaverna-vo-repository project and right click, and say "Add to build path".
Stian Soiland-Reyes: you need to do Right click and Maven -> Install first
you need to click on the sub-project
or better - do this for the whole astrotaverna/ project
Stian Soiland-Reyes: ah, sorry
Stian Soiland-Reyes: it is Run as -> Maven install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment