What is GitHub?

No Comments

Git allows a team of people to work together, all using the same files. And it also helps the team cope with the confusion that tends to happen when multiple people are editing the same files.

A few Git commands that can be run on command prompt once you install git on your desktop

Configure:
git config –global user.name “Sam Smith”
git config –global user.email sam@example.com

Create a new local repository:
git init

Check out a repository:
git clone /path/to/repository
For a remote server, user:
git clone username@host:/path/to/repository

Add files:
git add
git add *

Commit:
git commit -m “Commit message”
git commit -a

Push:
git push origin master

Status:
git status

Connect to a remote repository:
git remote add origin
git remote -v

Branches:
Create a new branch and switch to it:
git checkout -b

Switch from one branch to another:
git checkout

List all the branches in your repository, and also tell you what branch you’re currently in:
git branch

Delete the feature branch:
git branch -d

Push the branch to your remote repository, so others can use it:
git push origin

Push all branches to your remote repository:
git push –all origin

Pull changes from the repository:

git pull

Delete a branch on your remote repository:
git push origin :

Update from the remote repository
Fetch and merge changes on the remote server to your working directory:
git pull

To merge a different branch into your active branch:
git merge

View all the merge conflicts:
git diff

View the conflicts against the base file:
git diff –base

Preview changes, before merging:
git diff

After you have manually resolved any conflicts, you mark the changed file:
git add

Tags: You can use tagging to mark a significant change set, such as a release:

git tag 1.0.0
CommitId – is the leading characters of the changeset ID, up to 10, but must be unique. Get the ID using:
git log

 

Push all tags to remote repository:
git push –tags origin

Undo local changes:
git checkout —

Instead, to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this:
git fetch origin
git reset –hard origin/master

Search:
Search the working directory for foo(): git grep “foo()”

 

About us and this blog

We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

Request a free quote

We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

Subscribe to our newsletter!

More from our blog

See all posts

Leave a Comment