What is git? Git is a distributed version control system that helps track and manage changes in code over time. It allows multiple developers to work on the same project, view previous versions, and restore changes when needed.
Features of git: 1.Version Control System: Git keeps track of every change you make to your project files. You can go back to previous versions is any requirement arises.
- Repositories: A Git repository (or repo) is like a project's central hub where everything related to your work is stored and managed. There are two main types:
Local Repository: This is a copy of the repository which is stored in your computer. You can work on your project and make changes here.
Remote Repository: This is stored on a server, like GitHub, where you and others can share and work on a project.
Commits: Every time you make changes and save them in Git, these are called commits. The repository keeps track of all the commits you have made.
Branches: A repository allows you to create Branches and work on new features and fixes. For example, you can have a "main" branch for stable code and a "feature" branch for new features you're developing.
Merging: Once you are done with the branches you have made, you can merge those branches into main branch. This adds the changes you have made in the rest of the project.
Cloning: Cloning is a process of making a complete copy of Git repository. It's like copying the entire project from central location ( like website) to your own computer.
Basic Git Commands:
git init: Initializes a new Git repository.
git init
git clone [URL]: Clones a remote repository to your local machine.
git clone [url]
git add [file]: Stages changes to be committed.
git add [file]
git commit -m "message": Commits the staged changes with a message.
git commit -m "Your commit message"
git push: Pushes your commits to a remote repository.
git push origin branch-name
git pull: Fetches and merges changes from a remote repository to your local repository.
git pull origin branch-name
git status: Shows the status of changes in your working directory.
git status
Top comments (0)