sudo apt-get update && sudo apt-get install git -y
sudo yum install git -y
- Install homebrew and xcode
Git Operations on Node (Local)
- Lets create a git Repository
- Create a folder and cd into it
mkdir learninggit cd learninggit
- Mark this folder into repository by executing
- In Git we have 3 logical areas
- Working Tree
- Staging Area/Index Area
- Local Repo / git database
- Local Repo Workflow
- Make changes in Working Tree
- Add the changes to Staging Area
- Save the changes from Staging Area to Local Repo.
- Lets try this WF
- Create two file 1.txt and 2.txt
- Execute the command
- Now lets add the changes to staging area
git add 1.txt git status git add 2.txt git status
- Now lets try to commit the change from staging Area to Local Repo. To do this we can use the command
- This command requires 3 details
- Username and Email can be configured once at the system level, but message has to passed for every commit.
- To configure email and username
git config --global user.name "<yourusername>" git config --global user.email "<youremailid>"
- To commit the changes now execute
git commit -m "First Commit"
- To check the history, execute the following command
- For every change you get unique commit id as shown below
- Create a new folder called as docs
- Create one more folder called as test
- In the test folder create a new file called as 3.txt
- Now Execute
git statusand you will observed docs folder information is not shown in git status. Git never identifies empty directories.
- Now add the change to staging area
git add test/
- Now execute the following commands and observe the ouptut info
git commit -m "Second Commit" git status git log