Thursday 23 May 2019

GIT Commands


Step 1: Clone the project into local folder :
$ git clone <reviewbd url>
Step 2: Copy the project folder into the Local Folder
Step 3: To check the status use below command :
$ git status
Step 4: Add the Project Folder into repository.
$ git add <ProjectName>/
Step 5: Commit the Project/Files
$ git commit -m "initial commit for git and review"
Step 6: To check the repositories use below command
$ git remote -v
Step 7: To add the project into Remote location
$ git remote add origin git@<remoteServerip>:user1/user-project.git
Step 8: To Push the code
git push origin master
(OR)
git push origin HEAD:refs/for/master
Step 9: At any point you can view the history of your changes using
$ git log
Step 10: Create a new Branch
$ git branch <branch-name>
Step 11: To Check-out the branch
$ git checkout <branch-name>
Step 12: To Merge the code into master
$ git merge <branch-name>
Step 13: To Pull the code
$ git pull /home/lputta/ProjectName master
ex : git pull origin HEAD:refs/for/master
Step 14: To Tag the code
$ git tag v1.0 <Commit_Id>
Step 15: To check the difference
$ git diff
Step 16: To checkout files
$ git checkout <file-name-with-full-path>
ex : git checkout src/deploy/kubernetes/test.yaml
Step 17 : To reset the code changes
$ git reset --hard <change-Id>
ex : git reset --hard adsfadsf3434343da123dsfda11
Step 18 : To reset all the code changes
$ git reset .
ex : git reset . 
Step 19 : To Resolve the Merge Conflicts
i) git pull ==> if you get Merge Conflicts in your files.
ii) Take a back up of your files.
iii) Use git stash command to stash your changes
$ git stash
iv) Now again do pull you will get latest code.
$ git pull
v) Use pop command for merge with your changes in latest code.
$ git stash pop
vi) You will see some conflicts in your fles, please merge your changes in your workspace and commit your changes.

BitBucket Migration from GIT :

Process of Bitbucket migration

1. create repo “service-name” under https://bitbucket.elife.com/projects/lks

2. git clone ssh://lputta@reviewbd.harman.com:29440/services/service-name temp-dir

3. cd temp-dir

4. git remote set-url origin ssh://git@bitbucket.elife.com:7999/lks/service-name.git

5. git push -u origin --all 

6. git push origin —tags (Move all tags into the bitbucket)

Moving the sub-folder from Gerrit to bitbucket.
https://docs.github.com/en/get-started/using-git/splitting-a-subfolder-out-into-a-new-repository
https://ao.ms/how-to-split-a-subdirectory-to-a-new-git-repository-and-keep-the-history/

        1. git clone ssh://lokesh@reviewbd.elife.com:29440/service-name

        2. cd service-name

        3. git checkout master

        4. git filter-branch --prune-empty --subdirectory-filter service-name master

        5. create repo “service-name” under https://bitbucket.elife.com/projects/plk

        6. git remote set-url origin ssh://git@bitbucket.elife.com:7999/plk/service-name.git

        7. git push -u origin --all

        8. git push origin --tags


SpringBoot

SpringBoot SpringBoot Application :  Pros & Cons :  SpringBoot Application creation using spring.io :  SpringBoot Application Annotation...