Thursday, May 4, 2017

Git

Set up the initial global configuration
git config --global user.name "Anshul Sood"
git config --global user.email "anshulsood2006@gmail.com

Get all the configurations
git config --list

Get all the global configurations
git config --global --list

To get the help related to any/all commands
git help config
git help --all

To ignore a file in the git operations add them in .gitignore file e.g.
# ignore all bin directories matches "bin" in any subfolder
bin/
# ignore all target directories
target/
# ignore all files ending with ~
*~

To create a global gitignore to exclude bin folder
cd ~/
touch .gitignore
echo "bin" >> .gitignore
git config --global core.excludesfile ~/.gitignore

Create a git repository
Go to the folder
git init


Get the current status of git repository
git status

Add the file to staging area
git add file1 file2 file3
git all .

Commit files to local repository
git commit -m "Commit Message"

To get history
git log

To show the changes
git show

To revert the changes to a file
git checkout file1

To add to the remote repository
Create a repository on github and copy the URL
git remote add origin "https://github.com/anshulsood2006/Documentation.git"
git push origin {branchName}

If getting error
remote origin already exists
git remote rm origin
Updates were rejected because the tip of your current branch is behind
   git pull https://github.com/anshulsood2006/Documentation.git {branchName}
refusing to merge unrelated histories
   git merge origin/{branchName} --allow-unrelated-histories

To create a branch
git branch {branchName}

To go to the branch
git checkout {branchName}

To add brancb to remote
git push origin testing

To delete a branch
git branch -D {branchName}

To get the difference from the commit
git diff {fileName}

SpringBoot Application Event Listeners

When a spring boot application starts few events occurs in below order ApplicationStartingEvent ApplicationEnvironmentPreparedEvent Applicat...