Git is a version control system used to track changes in source code during software development. It allows multiple developers to work on the same project simultaneously without overwriting each other's work. Git helps you manage your code history, collaborate with others, and roll back to previous versions if needed.
git init command initializes a new repository or reintializes a existing repository. It will create a .git file that allows you to use git commands.
Example: git init .
git branch command displays the current local branch which we are working.
Example: git branch
git checkout command checks out to the branch. Append the command with branch name to checkout to the desired branch.
Example: git checkout <branchname>
git merge command combines the changes from one branch to another branch.
Example: git merge <branchname>
git add command stage changes in your current working directory whether it can be a single file or entire folder.
Example: git add readme.md (or) git add .
git commit command saves the changes staged in local repository with unique ID including comments of the changes.
Example: git commit -m "my changes"
git pull command gets all the changes from the remote repository to your local branch.
Example: git pull <remote> <branchname>
git push command transfers your local commits from your own branch to centralized remote repository.
Example: git push <remote> <branchname>
git fetch unlike git pull downloads only the latest changes from remote repository.
Example: git fetch <remote>
git diff command shows the differences between branches before committing or after pulling.
Example: git diff (or) git diff <branchname1> <branchname2>
git status command displays the current state of the working directory such as untracked files, changes that are going to commit.
Example: git status
git log command shows the history of commits in your repository with most recent changes.
Example: git log (or) git log --author="name"
Sessions to be added
We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.