Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Topic -1 about git hub

WHAT IS GITHUB?

• A central code base, or GitHub is a cloud-based service that


DEFINATION::
helps developers store, manage, and share their code. It uses Git, an open-
source version control software, to allow multiple people to work together
on web pages at the same time

• Git is a DevOps tool used for source code management. It is a free and open-source
version control system used to handle small to very large projects efficiently. Git is used
to tracking changes in the source code, enabling multiple developers to work to

Installation of GitHub

1. Create account on GitHub

1
2. https://github.com/login

installation of gitbash on your local computer

link:: https://git-scm.com/downloads

Download git bash and install the dependencies.

topic-2 creating the 1st repository on GitHub

1. To create a repository on GitHub


2. Open your GitHub account
3. Click on new repository.

4.type your repository name


2
5.click on create repository

6. your repository will be completed now

Topic-3 to add files in your repository


3
THERE ARE 3 METHODS
1.DRAG AND DROP
Check the google classroom video

2.UPLOAD THROUGH GIT BASH-


Check the google classroom video

3.UPLOAD THROUGH GIT HUB


Check the google classroom video

3. Upload through github ⬇️

Follow this command

• git init: This command creates a new Git repository in the current directory. This is the first
step to start tracking changes to your project files with Git.

• git clone: This command is used to clone an existing Git repository from a remote location,
typically a hosting service like GitHub. It creates a local copy of the repository on your
machine.

4
• git branch: This command is used to manage branches in your Git repository. Branches
allow you to work on different versions of your code independently. You can use git branch
to list existing branches, create new branches, and switch between branches.

• git add: This command tells Git which files you want to include in your next commit.
Changes to files that are not added will not be tracked by Git. You can add individual files or
use git add -A or use git add . to add all modified files in the working directory.

• git commit: This command captures a snapshot of the current state of your project. It creates
a new commit object in the Git repository history, along with a commit message that describes
the changes you made.

• git pull: This command is used to fetch the latest changes from a remote repository and
merge them into your local branch. It's a convenient shortcut for combining git fetch (which
downloads the changes) and git merge (which integrates them into your local branch).

• git push: This command is used to upload your local commits to a remote repository. This
allows you to share your changes with other collaborators or keep a backup of your project
online.

After that authentication through GitHub

5
Now You can upload your file through git bash

Topic-4 important git commands


6
1. git config --global user.name "name"

• Purpose: Sets your global Git username.


• Explanation: This command defines the name that will be associated with your Git
commits whenever you use Git on your machine. It's a good practice to use your real
name here for clarity and attribution.
• Example: git config --global user.name "Alice Smith"

2. git config --global user.email "email@female.com"

• Purpose: Sets your global Git email address.


• Explanation: This command defines the email address that will be associated with your
Git commits. It's important for receiving notifications and communication related to
your Git activity. While "female.com" is included in the example, you can replace it
with your actual email address.
• Example: git config --global user.email "alice.smith@example.com"

3. git config --global core.editor "code --wait"

• Purpose: Sets your preferred Git text editor globally.


• Explanation: This command tells Git which application to use when you need to edit
commit messages or other content. Here, "code" specifies the Visual Studio Code
editor, and "--wait" instructs Git to wait for the editor to close before continuing. You
can adjust this to match your preferred editor and its specific command-line arguments.
• Example: (assuming you use Sublime Text): git config --global core.editor
"subl -w" (where "-w" waits for Sublime Text to close)

4. git config --global core.autocrlf "input"

• Purpose: Configures Git's behavior regarding line endings on different operating


systems.
• Explanation: This command sets the core.autocrlf property to "input." Git
automatically converts line endings between operating systems (Windows uses CRLF,
Unix-based systems use LF) by default. With "input," Git will preserve the line endings
present in your files and not modify them.

5. git config --global -e

• Purpose: Opens your global Git configuration file for editing.


• Explanation: This command allows you to directly edit the Git configuration file,
which is typically located at %USERPROFILE%\.gitconfig on Windows. However, it's
generally recommended to use the specific git config commands for clarity and easier
management.

7
Topics-5 stages of git

. The stages are:

• U (untracked): This indicates that the file is not currently being tracked by Git. It exists
in your working directory, but any changes you make to it won't be included in your
Git commits.
• A (added or staged): This means the file has been added to the staging area, which is
a temporary holding spot for files you plan to include in your next commit. You can
use the git add command to stage files.
• C (committed): This signifies that the file is now part of a Git commit. A commit
creates a permanent snapshot of the state of your project at a specific point in time.

Other command in github

1. git log --oneline

• Purpose: Displays the Git commit history in a concise format, showing only the
abbreviated commit hash and the first line of each commit message on a single line.
• Example:

12a345b feat: Added new feature X


bcdedf3 bugfix: Resolved a bug Y
...

2. .gitignore

• Purpose: Creates a file named .gitignore in your repository. This file specifies
patterns of files or directories that Git should exclude from tracking. Any changes made
to files matching these patterns won't be reflected in your Git history.
• Example:

*.log # Ignore all log files


node_modules/ # Ignore the entire node_modules directory

8
3. git reset --hard HEAD~1

• Purpose: Moves your working directory (the files you're currently working with) and
the HEAD pointer (which points to the latest commit) one commit back in the Git
history. This effectively discards all changes you've made since the commit you're
resetting to (be very careful with this!).

4. git status -s

• Purpose: Provides a concise summary of the current status of your Git repository. It
shows which files are untracked (U), modified (M), staged (A), or deleted (D).
• Example:

M README.md # Modified file


?? config.json # Untracked file
A src/main.js # Staged file
D tests/old_test.py # Deleted file

5. git log

• Purpose: Displays the entire Git commit history, including the commit hash, author
name and email, commit date, and commit message for each commit.
• Example:

commit 12a345bfd3b12a...
Author: Alice Smith <alice@example.com>
Date: Thu May 23 14:38:20 2024 -0500

feat: Added new feature X

commit bcdedf3210abcde...
Author: Bob Jones <bob@example.com>
Date: Wed May 22 16:12:55 2024 -0500

bugfix: Resolved a bug Y


...

6. git branch (branch name)

• Purpose: Creates a new branch named according to the specified branch name.
Branches allow you to work on independent versions of your codebase simultaneously.
• Example:

git branch new-feature # Creates a new branch named "new-feature"

7. git branch

• Purpose: Lists all the branches currently existing in your Git repository.
• Example:

* master # Currently on the "master" branch (indicated by the asterisk)


new-feature
bugfix

9
8. git switch (branch name)

• Purpose: (Also known as git checkout) Switches your working directory to the
specified branch. This changes the files you're currently working with and the HEAD
pointer to reflect the branch you're switching to.
• Example:

git switch new-feature # Switches to the "new-feature" branch

9. git merge

• Purpose: Integrates changes from another branch (usually the development branch)
into the current branch (usually the master branch). This allows you to combine work
done on separate branches.
• Example:

git checkout master # Switch to the "master" branch


git merge new-feature # Merge changes from the "new-feature" branch in

10

You might also like