GitHub Learn final content (1)
GitHub Learn final content (1)
1. Version Control:
-Version control allows you to track and manage changes to files over time.
-Every time you make an update or add a new file, a new version is created.
-Importantly, this system doesn't modify older files.
-Instead, it stores the changes in a new version, preserving previous versions of your
code for future reference.
This sets your username as "snagendran" for all your future commits.
Step 2: Set Your Email Next:set your email address, which is associated with your Git
commits. Run the following command:
Step 3: List Git Configuration To verify the configuration you've set, you can list all your
global Git settings:
This will display the username, email, and other configurations you've set globally in Git.
PRACTICAL REF
ONCE DONE GIT WAS CREATED BY OWN
4. Commit History:
Commit: Every time you make changes and save them in Git, it creates a new version of
your project.
Staging Area: Before committing, your changes are placed in a "staging area." This area lets
you review and organize which changes you want to commit.
Each commit captures the state of the project at a particular moment in time, allowing you
to track the evolution of your project.
git init
git init: This command creates an empty Git repository in your project folder. Once this is
done, you can start tracking your files and making commits.
6. Git Status:
Once you've created a Git repository, you can track the status of your project with the
following command:
git status
git status: This command shows the current state of your working directory and staging
area.
It will tell you:
-Which files have been modified.
-Which files are staged and ready for committing.
-Which files are untracked (i.e., new files not yet added to Git).
git init -b main: This command initializes a new Git repository and sets the default branch
name to main instead of master.
Step 1: Create a File First, create a new file in your working directory. For example, you can
create a simple text file like Firstcode.txt (this could be a Java, C, C++, or any other type of
file).
Step 2: Check the Status Next, check the status of your Git repository by running:
git status
-git status will show you the current state of your working directory.
-Since this is a new file, it will be listed as untracked (i.e., Git hasn't started tracking it yet).
Step 3: Add the File to Git To start tracking the file, you need to add it to Git. Run the
following command:
-git add Firstcode.txt: This command stages the file, meaning it prepares it to be included
in the next commit.
-After running this command, the file is added to the staging area, which means it is ready
to be committed to your Git history.
This command commits Firstcode.txt to your Git repository with the commit message "Add
Firstcode.txt".
9.View the Commit History
To see your commit and track the history of changes, use:
git log
This will show a log of all your commits, including the one you just made for Firstcode.txt.
git add FirstProgram.txt: This command stages the changes made to the file, preparing it
for the next commit. It tells Git to track the new changes.
git commit -m "your commit message": This command commits the changes to your
repository with a message describing what you have done. In this case, the commit
message is "my second commit here".
git commit -a: This flag automatically stages all tracked files that have been modified (it
won’t include untracked or new files).
-m "message": The commit message describing the changes.
12. Checking Differences Using git diff:
If you’ve made changes to a file (for example, FirstProgram.txt) and want to see what
changes you’ve made before committing, you can use the git diff command to compare
the current version of the file with the version in the staging area or the last commit.
git rm --cached: This command removes the file from the staging area and the Git tracking
system, but it does not delete the file from your local working directory.
filename.txt: Replace this with the actual name of the file you want to remove (e.g.,
FirstProgram.txt).
Commit message: This will record that the file has been removed from Git's version
control but remains in your local directory.
CHAPTER 2 (GITHUB VS GIT )
1.Downloading source code in github
Method 1
-If the Github code want your machine go to github and press https and copy the url
And then go for a terminal and enter its start downloading
Method 2
-direct to download zip option
Creating a Folder and Working with Files Using CMD (Command Prompt)
1. Create a New Folder:
Example: To create a folder named MyProject:
mkdir MyProject
• Explanation:
o echo "# Git Your File Create": Adds the text # Git Your File Create.
o > README.md: Creates the file README.md with the content provided.
Example: Running cat README.md will show the content of the file:
# Git Your File Create
2.tagging
There two type of tagging
Once the new version released in compare to the previous release use to list the
tags
3.how to push tag
Chapter 5 branching
1.Create a new branch method1
Will any modification will be done in features1 branch once it will be switch to the main
branch its automatically disappears what are the changes will be made in this feature
branch
Which branch you want to push into the remote git in tnis case we add features 1 branch wil
be pushed
Am in main branch and merge the features branch into the main branch(don’t push in real
project directely)
6.how to pull
Once it will be pull merge changes will be seen in this github profile