Git bash commands

ls : list all files
ls -a : list all the hidden files
clear : clear the bash

git status : show status of current directory
git init : initialise Git repository
git config –global user.name “username : set the username for Git repository
git config –global user.email “emailaddress : set the e-mail address for the user
git add <filename>: add the file to Git repository
git commit -m “message : commit the Git action with message
git log : show the log of Git actions
git log -1 : show the last committed action
git show <4 characters of the Git commit id: show the log of the commit id and its contents differences made by the user
git diff : show the differences between local and Git repository
git checkout –<filename>  : restore the file from Git repository into local storage
sed ‘s/<originaltext>/<newtext>/g’ -i <filename> : replace the text in file
git revert <4 characters of the Git commit id>  : revert the commit to the previous state
git reset –hard <4 characters of the Git commit id> : reset the Git repository to its previous state, keep the commit actions before the Git commit id

vim .gitignore : open vim to write list of files to ignore
git checkout –. : close all unstaged changes

git remote add origin <remoterepositoryURL> : sets the new remoterepositoryURL
git remote -v : verifies the new remote URL

git push origin master : pushes the changes in local repository up to the remote repository
git push -f origin master : force it to push the changes in local repository up to the remote repository

GitHub reference for uploading local drive files into GitHub repository : https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

“Before a git push origin master you should do a git pull origin master to ensure you have the latest updates from the server.”

git pull origin master
git push origin master

Advertisements
Posted in Git

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s