GIT COMMANDS - CHEAT SHEET
What is GIT?
Git is a free and open-source distributed version control system for software development. It was initially created by Linus Torvalds in 2005 to manage the development of the Linux kernel, but it has since become one of the most popular version control systems in the world and is used for managing the source code of all kinds of software projects.
Git is designed to allow multiple developers to work on a project simultaneously and independently, while keeping track of all changes made to the code. It provides a mechanism for developers to save their work, track changes to their code over time, and collaborate with others on the same project.
Some key features of Git include its ability to create and manage multiple branches of code, its distributed architecture, and its support for non-linear development workflows. Git is also designed to be fast, efficient, and flexible, making it well-suited for a wide range of software development projects.
Git is widely used by software development teams around the world, including many large organizations such as Google, Facebook, and Microsoft. There are many different tools and services available that integrate with Git, including hosting services like GitHub, GitLab, and Bitbucket, and development environments like Visual Studio Code and Eclipse.
GIT BASICS | |
git init | will create a new local GIT repository. |
git clone | is used to copy a repository. |
git add | add a file as it looks now to your next commit(stage). |
git commit | will create a snapshot of the changes and save it to GIT directory. |
git push | push local changes to the original. |
GIT BRANCHING AND MERGING | |
git branch | will list your branches. |
git checkout | switch to another branch and check it out into your working directory. |
git merge | will merge the specified branch's history into the current branch. |
git log | show all commits in the branch's history. |
MAKE A CHANGE | |
git status | list new or modified files not yet committed. |
git diff | stages the file, ready for commit. |
git add(file) | will merge the specified branch's history into the current branch. |
git reset(file) | unstages file,keeping the file changes. |
git commit -m ["descriptive message"] | commit all stages files to versioned history. |
SYNCHRONIZE | |
git remote add [name][url] | create a new connection to a remote repo. |
git fetch | get all the changes from the origin(no merge). |
git pull | get all the latest from the origin and merge. |
git Push | is used to upload your local repository changes to the origin remote repo. |
No comments: