0% found this document useful (0 votes)
24 views

Git

- Git is a version control tool that allows tracking changes to code, synchronizing code between collaborators, testing changes without affecting original code, and reverting to previous versions. - GitHub is a platform for hosting Git repositories online that makes it easy to share code and collaborate with others. - Git commands like git clone, add, commit, push, pull, branch, merge, and reset allow managing changes locally and synchronizing with remote repositories.

Uploaded by

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

Git

- Git is a version control tool that allows tracking changes to code, synchronizing code between collaborators, testing changes without affecting original code, and reverting to previous versions. - GitHub is a platform for hosting Git repositories online that makes it easy to share code and collaborate with others. - Git commands like git clone, add, commit, push, pull, branch, merge, and reset allow managing changes locally and synchronizing with remote repositories.

Uploaded by

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

Git:

Git is a version control tool.


It is a command line tool that allows us to: - Keep track of the changes to
code(by saving snapshots of some parts of our code).
- Synchronize code between diffrend people (using a
rep, then pushing them to the server, then pull from the server).
- Test changes to code without losing access to the
original( Using branches, then merge).
- Revert back to old versions of code.
A commit is a saving point
GitHub:
GitHub is an online platform(website) that allows us to save hosts git reps.

Merge Conflicts: hash,


Branching: master, feature, switching head, then we merge
Forking is creating a version of an existing rep into your github account that you
can contribute to
GitHub Paging is a free feature that allows you to kindda host your website in : -
Create a new rep : username.github.io

Git Commands:
.gitignore file and type in the names of the files and folders that you dont want
to add
git init
git remote add origin url
git remote set-url origin url, [email protected]........
git clone url nickname` --> clone and download the rep form GitHub to local pc
git add, stage changes for next commit
git commit -[a]m "message", s
git status
git push --set-upstream origin mainf
git push origin main, main is the branch
git pull
git log --> show you all the commits you have done
git reset --hard 'commit hash'/ origin/master
git branch
git branch -D branch name to delete
git checkout [-b ]'name', move between commits
git merge 'name'
git config --gloval user.name "name"
git config --global user.email "email"

detailed summery:
- Git is a version control tool used to keep track of changes in code
- It allows for easy synchronization of code between different people working on
the same project
- Git enables testing changes to code without removing access to the original
- It also allows for reverting back to old versions of code
- GitHub is a popular website for hosting Git repositories
- You can clone a repository from GitHub to download it onto your computer using
the `git clone` command
- Changes made locally need to be pushed to GitHub using `git push` to update the
online version
- To download the latest changes from GitHub, use `git pull`
- Merge conflicts may occur when trying to merge changes from different branches,
and need to be resolved manually
- Branching allows for working on different parts of a project simultaneously
- GitHub provides the option to fork a repository, make changes, and submit pull
requests to contribute to the original code
- GitHub Pages allows for easy deployment of websites by hosting HTML, CSS, and
JavaScript files on GitHub

How Git stores data: Key-value (Object database) in the .git folder, there are
three types of objects: commits, trees and blobs
README.md is a mark down file that uses special language to structor information

git init: Initializes a new Git repository in the current directory, creating
a .git subdirectory that stores the repository's configuration and history.

git clone <repository_url>: Copies a remote repository to your local machine,


creating a working copy of the project.

git add <file>: Stages changes to the specified file, preparing them to be
committed.

git add . or git add -A: Stages all changes in the working directory for the next
commit.

git commit -m "message": Records the staged changes in a new commit along with a
descriptive message.

git status: Shows the current status of the working directory, indicating
untracked, modified, and staged files.

git log: Displays a history of commits, showing details such as commit messages,
authors, and timestamps.

git pull: Fetches changes from a remote repository and integrates them into the
current branch.

git push: Pushes your local commits to a remote repository, making your changes
available to others.

git branch: Lists all branches in your repository, indicating the currently
checked-out branch.

git branch <branch_name>: Creates a new branch with the specified name.

git checkout <branch_name>: Switches to the specified branch.

git checkout -b <new_branch>: Creates a new branch and immediately switches to it.

git merge <branch_name>: Combines changes from the specified branch into the
current branch.

git rebase <branch_name>: Reorganizes commits to incorporate changes from the


specified branch into the current branch, creating a linear history.

git reset <file>: Unstages the changes for the specified file, leaving your working
directory unchanged.

git reset --hard <commit_hash>: Resets the repository to a specific commit,


discarding all changes after that commit.
git stash: Temporarily saves changes in your working directory without committing
them, allowing you to switch branches or perform other operations.

git remote -v: Lists the remote repositories associated with your local repository,
showing their URLs.

git fetch: Downloads new changes from a remote repository without merging them into
your local branch.

You might also like