Thursday, December 5, 2019

GIT

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).
 




  • git init creates a new Git repository
  • git status inspects the contents of the working directory and staging area
  • git add adds files from the working directory to the staging area
  • git diff shows the difference between the working directory and the staging area
  • git commit permanently stores file changes from the staging area in the repository
  • git log shows 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.


Search This Blog

Powered by Blogger.

GIT

Create a sample.txt file Sample Folder. In sample folder directory run command prompt Run git init to initialise git in the directory g...