Git Common Commands
Git Common Commands
http://git.caretit.com/
On click of any repository user can see all details of that repository.
Here are the list of all branches of selected repository.
Here are the URL for clone repository, we have 2 options for clone repository, one is SSH and other one is
HTTPS, if SSh key is configured in user account then clone is possible with SSh otherwise user can use
HTTPS.
Here are the Git commands which are being covered:
● git config
● git clone
● git add
● git commit
● git diff
● git reset
● git status
● git rm
● git log
● git show
● git tag
● git branch
● git checkout
● git merge
● git remote
● git push
● git pull
● git stash
Git Commands
git config
Usage: git config –global user.name “[name]”
This command sets the author name and email address respectively to be used with your commits.
git clone
Usage: git clone [url]
git branch
Usage: git branch
This command lists all the local branches in the current repository.
git checkout
Usage: git checkout [branch name]
git status
Usage: git status
git add
Usage: git add [file]
git diff
Usage: git diff
This command shows the file differences which are not yet staged.
This command shows the differences between the files in the staging area and the latest version present.
git commit
Usage: git commit -m “[ Type in the commit message]”
This command records or snapshots the file permanently in the version history.
This command commits any files you’ve added with the git add command and also commits any files you’ve
git log
Usage: git log
This command is used to list the version history for the current branch.
This command lists version history for a file, including the renaming of files also.
git show
Usage: git show [commit]
This command shows the metadata and content changes of the specified commit.
git reset
Usage: git reset [file]
This command unstages the file, but it preserves the file contents.
This command undoes all the commits after the specified commit and preserves the changes locally.
Usage: git reset –hard [commit] This command discards all history and goes back to the
specified commit.
Be careful when using “–hard” : changes will be removed from the working directory and from the index,
Usage: git reset --soft [commit] The last commit will be removed from your Git history.
The --soft option means that you will not loose the uncommitted changes you may have.
If you want to reset to the last commit and also remove all unstaged changes, you can use the
--hard option
git rm
Usage: git rm [file]
This command deletes the file from your working directory and stages the deletion.
git tag
Usage: git tag [commitID]
This command merges the specified branch’s history into the current branch.
git remote
Usage: git remote add [variable name] [Remote Server Link]
This command is used to connect your local repository to the remote server.
git push
Usage: git push [variable name] master
This command sends the committed changes of master branch to your remote repository.
git pull
Usage: git pull [Repository Link]
This command fetches and merges changes on the remote server to your working directory.
git stash
Usage: git stash save