Professional Documents
Culture Documents
Git
Git
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, username@githun.com........
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 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 -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 reset <file>: Unstages the changes for the specified file, leaving your working
directory unchanged.
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.