Git is a powerful tool for managing the codebase of a project and collaborating with other developers. Whether you are working on a small personal project or a large team-based project, Git is a great choice for version control.
There are several common things related to Git that every developer should know about. Here are some of the most important
A repository is a central location where all the code, files, and history of a project are stored. You can create a new repository or clone an existing one to work on.
A branch is a separate line of development in Git that allows you to work on new features or bug fixes without affecting the main codebase. Once you're done with your changes, you can merge your branch back into the main codebase.
A commit is a snapshot of the changes made to a file or set of files. Each commit has a unique identifier and a commit message that describes the changes made.
A merge is the process of combining changes from one branch into another. This is typically done when a feature or bug fix is complete and needs to be merged back into the main codebase.
A pull request is a request to merge changes from one branch to another. It allows other developers to review the changes and provide feedback before they are merged.
A remote is a copy of a repository that is hosted on a server or online service, such as GitHub or GitLab. You can push your changes to a remote to share your work with other developers.
A clone is a copy of a repository that is downloaded to your local machine. Cloning a repository allows you to work on it locally and make changes before pushing them back to the remote.
A fork is a copy of a repository that is made on a remote service, such as GitHub. Forking a repository allows you to make changes to the code without affecting the original repository.
Overall, these are just a few of the many common things related to Git. Understanding these concepts is essential for anyone working with Git, as they form the foundation of version control and collaboration.
This command adds changes made to a file or set of files to the staging area. The staging area is where you can review and prepare changes before committing them.
git add file_name or git add .
is a command used in Git to interactively stage changes to a file. The -p flag stands for "patch," and it allows you to review each change to the file and decide whether to include it in the commit or not..
git add -p ((1/1) Stage this hunk [y,n,q,a,d,e,?]?)
This command creates a new commit with the changes made to the files in the staging area. Each commit has a unique identifier and a commit message that describes the changes made.
git commit -m "here your message"
This command uploads changes from your local repository to a remote repository. This is typically done to share changes with other developers or to update the codebase in a shared repository.
git push origin feature_branch_name
This command downloads changes from a remote repository and merges them into your local repository. This is typically done to update your local repository with changes made by other developers.
git pull origin master
This command temporarily saves changes that are not yet ready to be committed. This is useful when you need to switch to a different branch or work on a different task without losing your changes.
git stash
In This command in Git that displays a list of all stashes that are currently saved in the repository. The command displays the stash reference, the message associated with the stash, and the date and time the stash was created.
git stash list
This command applies changes saved in the stash back to the working directory. This is useful when you want to retrieve changes that were saved using git stash
git stash pop
This command applies changes saved in the stash back to the working directory.
git stash apply