0% found this document useful (0 votes)
16 views5 pages

Unit 2 - Getting Started With GIT

This document provides an introduction to setting up a Git environment, including configuring user identity and verifying configurations. It also outlines various Git tools, terminologies, and essential commands for managing repositories, commits, branches, and collaboration. Key concepts such as pull requests, merge conflicts, and the use of Gitignore are explained to facilitate effective version control and software development.

Uploaded by

mecap69891
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

Unit 2 - Getting Started With GIT

This document provides an introduction to setting up a Git environment, including configuring user identity and verifying configurations. It also outlines various Git tools, terminologies, and essential commands for managing repositories, commits, branches, and collaboration. Key concepts such as pull requests, merge conflicts, and the use of Gitignore are explained to facilitate effective version control and software development.

Uploaded by

mecap69891
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Unit -2 Getting started with GIT

GIT Environment Setup


Setting up your Git environment involves configuring your identity, choosing default behaviors,
and customizing your workflow.

Configure Your Identity: Open Git Bash (or your terminal) and run the following commands,
replacing the placeholders with your actual information:

arduinoCopy code

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

These commands set your name and email as the default identity for your Git commits.

Check Your Configuration: You can verify your configuration by running:

luaCopy code

git config --global user.name

git config --global user.email

Verify Your Configuration: You can view your entire Git configuration by running:

cssCopy code

git config --list –global

GIT Tools
There are several tools and software applications that complement and enhance the experience
of using Git for version control and collaborative software development. Here are some
commonly used Git tools:

Git GUI Clients: These are graphical user interface applications that provide a visual way to
interact with Git repositories. They can be especially helpful for those who prefer a more visual
approach to managing version control.

 GitKraken
Unit -2 Getting started with GIT

 SourceTree

 GitHub Desktop

Diff and Merge Tools: These tools help you visualize and manage differences between versions
of files, making it easier to understand changes and resolve conflicts.

 KDiff3

 Beyond Compare

 P4Merge

Code Review Platforms: While not Git tools in the traditional sense, code review platforms
integrate with Git repositories to facilitate collaboration and peer code reviews.

 GitHub, GitLab, Bitbucket

 Gerrit

Git LFS (Large File Storage): Git LFS is an extension that manages large files in Git repositories,
storing them externally and replacing them with pointers in the repository to save space and
improve performance.

GIT Terminologies
1. Repository (Repo): A directory or storage space where your projects can live. It contains
all the files, history, and configuration related to your project.

2. Commit: A snapshot of your project's state at a particular point in time. Each commit
represents a set of changes made to files.

3. Branch: A separate line of development. You can think of it as a parallel version of the
repository. Branches are often used for developing new features or isolating bug fixes.

4. Master/Main Branch: The default branch in a Git repository. It typically represents the
main line of development and is considered stable.

5. Clone: Creating a copy of a repository from a remote source onto your local machine.

6. Remote: A version of your repository stored on a server, often hosted by a platform like
GitHub, GitLab, or Bitbucket.
Unit -2 Getting started with GIT

7. Pull: Fetching changes from a remote repository and merging them into your local
branch.

8. Push: Sending your committed changes to a remote repository. This updates the remote
repository with your changes.

9. Merge: Combining the changes from one branch into another. For example, merging a
feature branch into the main branch.

10. Pull Request (PR): A request to merge changes from one branch into another. It's a
common workflow for collaboration and code review.

11. Fork: Creating a personal copy of someone else's repository. This allows you to make
changes without affecting the original repository.

12. Conflict: A situation that occurs when Git cannot automatically merge changes due to
conflicting edits in the same part of a file. Conflicts must be resolved manually.

13. Merge Conflict: An occurrence of conflicting changes that need to be resolved before a
merge can be completed.

14. Tag: A reference to a specific commit, often used to mark a version or release point.

15. Pull Request Review: The process of reviewing and discussing changes proposed in a
pull request before merging.

16. Gitignore: A file that specifies which files and directories should be ignored by Git,
usually because they are not relevant to the project or contain sensitive information.

17. Staging Area (Index): A temporary area where you can stage changes before committing
them. It allows you to control which changes are included in the next commit.

18. HEAD: A reference to the latest commit in the currently checked-out branch. It
represents your current working state.

19. SHA-1 Hash: A unique identifier for a commit or an object in the Git repository. It's a
long alphanumeric string.

20. Rebase: A process of moving or combining a sequence of commits to a new base


commit. It's often used to integrate changes from one branch onto another more
cleanly than merging.
Unit -2 Getting started with GIT

GIT Commands
1. Creating and Cloning Repositories:

 git init: Initialize a new Git repository in the current directory.

 git clone <repository_url>: Clone a remote repository onto your local machine.

 git remote add origin < repository_url >: Add local directory to the remote
repository

2. Committing Changes:

 git add <file>: Stage changes for commit.

 git commit -m "Commit message": Commit staged changes with a descriptive


message.

3. Branches:

 git branch: List all branches in the repository.

 git branch <branch_name>: Create a new branch.

 git checkout <branch_name>: Switch to a different branch.

 git merge <branch_name>: Merge changes from one branch into the current
branch.

 git rebase <branch_name>: Rebase the current branch onto another branch.

4. Remote Repositories:

 git remote -v: List remote repositories associated with your local repository.

 git remote add <remote_name><repository_url>: Add a remote repository.

 git push <remote_name><branch_name>: Push local commits to a remote


repository.

 git pull <remote_name><branch_name>: Pull and merge changes from a remote


repository.

5. Pull Requests and Collaboration:


Unit -2 Getting started with GIT

 git fetch: Retrieve changes from a remote repository without merging them.

 git pull-request: Create a pull request (this command varies based on the
platform you're using, like GitHub or GitLab).

 git checkout -b <new_branch>: Create a new branch and switch to it in one step.

6. Viewing History and Changes:

 git log: View commit history.

 git diff: Show changes between working directory and the last commit.

 git diff <commit1>..<commit2>: Show changes between two commits.

 git show <commit>: Show details of a specific commit.

7. Undoing Changes:

 git reset <file>: Unstage changes from a file.

 git checkout -- <file>: Discard changes in the working directory for a file and
revert to the last commit's version.

 git revert <commit>: Create a new commit that undoes changes made in a
previous commit.

8. Tags:

 git tag: List all tags in the repository.

 git tag -a <tag_name> -m "Tag message": Create an annotated tag.

 git push <remote_name><tag_name>: Push a specific tag to a remote repository.

9. Gitignore and Cleanup:

 Create a .gitignore file to specify files and patterns to be ignored by Git.

you can use git --help or git <command> --help to access the built-in Git documentation for any
specific command.

You might also like