Create a sample.txt file Sample Folder.
In sample folder directory run command prompt
Run git init to initialise git in the directory
git init - working directory - git add - staging area - git commit - repository
Now track the text file with git add sample.txt to track the file.
Tracked file changes can be seen with git diff sample.txt
Differences are prefixed with + symbol
Now add the changes to staging are with git add sample.txt
Commit is the final step. Message is added along with a commit (50 Characters)
git commit -m "First Commit" command is used to staged files.
Commit logs can be seen with git log command.
Why Branch?
To have multiple version. (Happy ending, Sad Ending).
In sample folder directory run command prompt
Run git init to initialise git in the directory
git init - working directory - git add - staging area - git commit - repository
Now track the text file with git add sample.txt to track the file.
Tracked file changes can be seen with git diff sample.txt
Differences are prefixed with + symbol
Now add the changes to staging are with git add sample.txt
Commit is the final step. Message is added along with a commit (50 Characters)
git commit -m "First Commit" command is used to staged files.
Commit logs can be seen with git log command.
Why Branch?
To have multiple version. (Happy ending, Sad Ending).
git initcreates a new Git repositorygit statusinspects the contents of the working directory and staging areagit addadds files from the working directory to the staging areagit diffshows the difference between the working directory and the staging areagit commitpermanently stores file changes from the staging area in the repositorygit logshows a list of all previous commits
git checkout HEAD filename: Discards changes in the working directory.git reset HEAD filename: Unstages file changes in the staging area.git reset commit_SHA: Resets to a previous commit in your commit history.
git branch: Lists all a Git project’s branches.git branch branch_name: Creates a new branch.git checkout branch_name: Used to switch from one branch to another.git merge branch_name: Used to join file changes from one branch to another.git branch -d branch_name: Deletes the branch specified.