Basic Git Workflow:
- Git is a software that allows you to keep track of changes made to a project over time. Git works by recording the changes you make to a project, storing those changes, then allowing you to reference them as needed.
- Turning a directory into a project>> command: git init
The word
init means initialize. The command sets up all the tools Git needs to begin tracking changes made to the project.
Output: would be like- Initalized an empty git repository in /home/ccuser/workspace/sorcerers-code/.git/
By the above output, we could say that The Git project was created.
- Git workflow:
A Git project can be thought of as having three parts:
- 1. A Working Directory: where you'll be doing all the work: creating, editing, deleting and organizing files
- 2. A Staging Area: where you'll list changes you make to the working directory
- 3. A Repository: where Git permanently stores those changes as different versions of the project
The Git workflow consists of editing files in the working directory, adding files to the staging area, and saving changes to a Git repository.
- Check status of changes in working dir>> Command: git status
In the output, notice the file in red under
untracked files. Untracked means that Git sees the file but has not started tracking changes yet.- In order for git to start tracking, the file needs to be added to the staging area. We can add a file to the staging area with-
Command: git add filename
After adding file, check the status.
Output:
In the output, notice that Git indicates the changes to be committed with "new file: filename.fileformat" in green text. Here Git tells us the file was added to the staging area. - Check the differences of work between working directory and staging area:
Notice the output:
- "Our first added change" is in the staging area, as indicated in white.
- Changes to the file are marked with a
+and are indicated in green.IMPORTANT: pressqon your keyboard to exit diff mode. - After the above step, add the changes to the staging area in Git.
- Committing changes:A commit is the last step in our Git workflow. A commit permanently stores changes from the staging area inside the repository.
git commitis the command we'll do next. However, one more bit of code is needed for a commit: the option-mfollowed by a message. Here's an example:git commit -m "Complete first line of dialogue"Standard Conventions for Commit Messages:- 1. Must be in quotation marks
- 2. Written in the present tense
- 3. Should be brief (50 characters or less) when using
-m
- View log:

Let's take a recap:
- 1. Git is the industry-standard version control system for web developers
- 2. Use Git commands to help keep track of changes made to a project:
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
Courtesy:
www.codecademy.com
MicrowaveSam (https://www.youtube.com/watch?v=73I5dRucCds)
www.codecademy.com
MicrowaveSam (https://www.youtube.com/watch?v=73I5dRucCds)

Comments
Post a Comment