Step 1: Create a Github Account
- Go to https://github.com and click on Sign up for GitHub
- Provide with your details – username, email address, password & click on Create Account
Output
<html> sa source code
sda dsadas sadd
Step 2: Create a Repository
- Click on Create a new repository
- Create a Public Repository by name centralrepo
Step 3: Launch two EC2 instances in two regions (Mumbai & London).
Run below commands in both machines
- sudo su –
- yum update –y
- yum install git –y
- git –-version
- git config –-global user.name “Ram/Shyam”
- git config –-global user.email ram/[email protected]
- git config –list
- git remote add origin https://github.com/RST-10/centralrepo.git
Step 4: Git Commands in Mumbai EC2
Create directory & go inside that
- mkdir mumbaigit
- cd mumbaigit
- git init (to initialize git)
Create new file, see status, put in staging area & commit into local repo
- touch myfile (put some content)
- git status
- git add .
- git commit –m “1st commit from Mumbai”
- git log
- git show <commit-id>
- git push origin master
Step 5: Git Commands in London EC2
Create directory & go inside that
- mkdir londongit
- cd londongit
- git init (to initialize git)
- git remote add origin <centralgit repo url>
- git pull origin master
- git log
- git show <commit-ID>
- cat >> file1 (append with some content)
- git status
- git add .
- git commit –m “1st commit from London”
- git push –u origin master
Step 6: Git Log
Git log options
- git log
- git log –1
- git log –oneline
To pic commit based on commit message
- git log –grep “any word of commit msg”
To see the content of particular commit
- git show <commit-ID>