Saturday, January 27, 2018

Git Workflow and commands | Git popular commands

git init

This command turns a directory into an empty Git repository. This is the first step in creating a repository. After running git init, adding and committing files/directories is possible.

git add

Adds files in the to the staging area for Git. Before a file is available to commit to a repository, the file needs to be added to the Git index (staging area). There are a few different ways to use git add, by adding entire directories, specific files, or all unstaged files.

git commit

Record the changes made to the files to a local repository. For easy reference, each commit has a unique ID.
It’s best practice to include a message with each commit explaining the changes made in a commit. Adding a commit message helps to find a particular change or understanding the changes.

git status

This command returns the current state of the repository.

git clone

To create a local working copy of an existing remote repository, use git clone to copy and download the repository to a computer.

git fork
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.

git pull
To get the latest version of a repository run git pull. This pulls the changes from the remote repository to the local computer.

git push

Sends local commits to the remote repository. git push requires two parameters: the remote repository and the branch that the push is for.

git checkout

To start working in a different branch, use git checkout to switch branches.

git merge

Integrate branches together. git merge combines the changes from one branch to another branch. For example, merge the changes made in a staging branch into the stable branch.

git commit --amend

You can also re-write history of your most recent commit in your local git repository by using git commit --amend command.

git commit --amend

No comments:

Post a Comment