Working of Git
Step 1: Install Git and Initialize Repository
- Install Git on Amazon EC2 instance using the command:
sudo yum install git -y
- Create a directory (replace 'dir_name' with your preferred name):
mkdir dir_name
- Navigate to the directory:
cd dir_name
- Initialize a new Git repository:
git init
Step 2: Create a File, Stage and Commit
- Create a file (replace 'file_name' with your preferred name):
touch file_name
- Add the file to the staging area:
git add file_name
- Commit the file to the local repository (replace 'commit_message' with your preferred message):
git commit -m 'commit_message'
- Check the status of your file:
git status
Step 3: Configure Git Global Variables
- Configure Git global variables (replace 'user.name' and 'user.email' with your preferred username and email):
git config --global user.name "username"
git config --global user.email "email"
git config --list"
Step 4: Use Git Show and Git Log Commands
- Use the Git show command to see the changes made in the last commit:
git show
- Use the Git log command to see the commit history:
git log