Basic Git commands

By February 27, 2017 GIT No Comments
Basic Git commands

Basic Git commands

Here are the list of some basic Git commands that every beginners should know.

1 Create a new repository create a new directory, open it and perform a git init to create a new git repository.
2 Checkout a repository You can create a working copy of a local repository by running the command
git clone /path/to/repository

You can also use a remote server url to clone repository,  your command will be
git clone username@host:/path/to/repository

 3  Adding changes file You can propose changes (add it to the Index) using
git add index.html style.css function.js or git add *
 4 Commit or saving your local changes This is the first step in the basic git workflow . Now the files is committed in your local repository.  To actually commit these changes use
git commit -m "Commit message"
5 Pushing Your Changes Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute
git push origin development[Branch Name]
6 Creating Branch Branches are used to develop  features or functionality isolated from each other.  Master branch is the “default” branch when you create a repository. You can use other branches for development and merge them back to the master branch upon completion to collect all of your individual module. -Create a new branch named “design_branch” and switch to it using
git checkout -b design_branch git checkout master
7 Deleting branch any off your breach can be delete using -d.
git branch -d design_branch
8 Update & Merge To update your local repository to the newest commit, execute
git pull in your working directory to fetch and merge remote changes.
To merge another branch into your active branch (e.g. master), use
git merge branch_name in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in conflicts. You are responsible to merge those conflicts manually by editing the files shown by git. After changing, you need to mark them as merged with
git add filename

About Vijay Dhanvai

A passionate blogger by heart and mind, I have been working in this field for 7 years now. A WordPress Professional, web developer and designer who intends to guide his readers about Web Design, WordPress, Blogging, Web Development, and more.

Leave a Reply