Wednesday, April 6, 2016

Git

1. Download git for mac - https://git-scm.com/download/mac
2. Git immersion tutorial - basics - http://gitimmersion.com/lab_01.html
3.Create maven project - https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
4. Spring dependencies on maven and sample spring boot for microservice
https://spring.io/guides/gs/spring-boot/
5. Install insomnia rest - google chrome app for handling rest calls and parameter

***Don't forget to add .gitignore before uploading in remote Git lab or github.

Git upload code to remote repo
read more  - http://stackoverflow.com/questions/2866872/how-can-i-upload-fresh-code-at-github

1.project location - /kavita/projects/sentiment
$git init
$git add .
$git status
$git commit -m "initial commit"
This will commit all the files of the project "Sentiment" in local git repo.

2.Create repo in github or gitlab
You will get following instructions to push the code. Last set of instructions "existing git repo" is of relevance to us since in above step we have created a local ( in my machine ) git repo.

Git global setup:
git config for username and email will be mentioned here.

Create repository:
mkdir sentiment
cd sentiment
touch README
git add README
git commit -m "first commit"
git remote add origin git@ipaddress:username/repoName
git push -u origin master

existing git repo: [ in our case we already have a local repo ]
cd sentiment
git remote add origin git@ipaddress:username/repoName
git push -u origin master

3. If by chance you pushed the project to git without adding .gitignore, then later you can remove by
$git rm --cached filename.txt
$git commit -m "deleted"
$git push origin master
read here more
http://stackoverflow.com/questions/2047465/how-can-i-delete-a-file-from-git-repo

4. $git reset --hard <commitid> ----> will bring the state of the project to the previous commit and all new files will be removed from the repo and intellij
try revert.

git reset --hard 3fc5f61 instead try
git revert 3fc5f61


* 9710675 2016-04-12 | Added sentiment algorithm & reading properties externally (HEAD -> master) [kavita.ganeshan]
* 3fc5f61 2016-04-06 | deleted iml file (origin/master) [kavita.ganeshan]
* a761f1d 2016-04-06 | added new file [kavita.ganeshan]
* a8d14a2 2016-04-06 | initial commit [kavita.ganeshan]
Kavitas-Mac:sentiment kavitaganeshan$ git revert 3fc5f61
[master daf15eb] Revert "deleted iml file"
 1 file changed, 57 insertions(+)
 create mode 100644 sentiment.iml
Kavitas-Mac:sentiment kavitaganeshan$ git hist
* daf15eb 2016-04-12 | Revert "deleted iml file" (HEAD -> master) [kavita.ganeshan]
* 9710675 2016-04-12 | Added sentiment algorithm & reading properties externally [kavita.ganeshan]
* 3fc5f61 2016-04-06 | deleted iml file (origin/master) [kavita.ganeshan]
* a761f1d 2016-04-06 | added new file [kavita.ganeshan]
* a8d14a2 2016-04-06 | initial commit [kavita.ganeshan]

revert puts it as new commit id.

on merge conflicts, do git status and modify required files.
**********************
Working on remote development branch and creating a new branch.

http://makandracards.com/makandra/521-check-out-a-remote-branch-in-git
git fetch origin
git checkout development

git pull branch / git pull origin development
git checkout branchid
git rebase development - local changes on older version files will be replaced with.
git commit -m ""
git push origin branchid

To check build - mvn clean package.

First time pull from remote branch
git clone https://projectname.git
****************

delete branch - git branch -d SF-1
*********



Intellij

Run another spring service on different port - http://codedevstuff.blogspot.in/2015/05/change-port-on-spring-boot-application.html

*****************
Explicitly add GSON through maven in intellij when auto-import doesn't work
https://www.jetbrains.com/help/idea/2016.1/downloading-libraries-from-maven-repositories.html?origin=old_help

*******************

Exception handling returns http error codes
https://dzone.com/articles/exception-handling-spring-rest

No comments:

Post a Comment