Free GIT Command Line

  • git config

Assign configuration values ​​for your user name, email, gpg key, the preferred diff algorithms, file formats and much more. Example:

1
2
git config -global user.name “My Name”
git config -global user.email ” [email protected] “
  • git init

Initializes a git repository – makes the initial git directory within a new or existing project. Example:

1
2
git init 
initialized empty Git repository in /home/username/GIT/.git/
  • git clone

Make a copy of the GIT repository of resources remotely. Add also the original location as the remote so that you can pick it up again and push if you have permission. Example:

1git clone [email protected] : user / test.git
  • git add

Adding a file changes in your working directory to your index. Example:

1git add.
  • git rm

Deleting files from your index and your working directory so that they will not be tracked. Example:

1git rm filename
  • git commit

Taking all that is written in the index changes, create a new commit object that points to it and set up a branch to point to the new commit. Example:

12git commit -m ‘added committing changes’
git commit -a -m “committing all changes, equals to git add and git commit’
  • git status

Displays status versus the index file in the working directory. It will list the files that are not tracked (just in your working directory), modified (tracked but has not been updated in your index), and staged (added to the index and you are ready to be committed). Example:

1
2
3
4
5
6
78
git status 
# On branch master #
# Initial commit #
# Untracked files: #
# (use “git add <file> …” to include in what will be committed) # 

README
  • git branch

List of existing branches, including branches remotely if the ‘-a’ are provided. Creating a new branch if the branch name is provided. Example:

1git branch -a * master remotes / origin / master
  • git merge

Combining one or more branch into your current branch and automatically creates a new commit if there is no conflict. Example:

1git merge newbranchversion
  • git reset

Resetting the index and your working directory to the status of your last commit. Example:

1git reset HEAD -Hard
  • git tag

Marking certain commitments with simple hand human readable never move. Example:

1git tag -a v1.0 -m ‘this is version 1.0 tag’
  • git pull

Retrieve files from remote repositories and combine them with local ones. Example:

1git pull origin
  • git push

Encourages all local objects are modified to a remote repository and promote branches. Example:

1git push origin master
  • git remote

Showing all remote versions of your repository. Example:

1git remote origin
  • git log

Shows a list of commits in the branch including the relevant details. Example:

git log commit 

84f241e8a0d768fb37ff7ad40e294b61a99a0abe Author: User < [email protected] > Date: Mon May 3 09:24:05 2010 +0300 first commit
  • git diff

Generate a patch file or statistical differences between the path and the file in your git repository, or your index or your working directory. Example:

1git diff
  • git archive

Creating a tar or zip file including the contents of the tree of your repository. Example:

1git master archive zip -format = ^ README> file.zip
  • git gc

Garbage collector to your repository. Optimize your repository. Should be run occasionally. Example:


git gc 

Counting objects: 7, done.
Delta compression using up to two threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), done.
Total 7 (delta 1), reused 0 (delta 0)
  • git fsck

Is Git file system integrity checks, identify objects damaged. Example:

1git fsck
  • git prune

Delete objects that are no longer guided by any object in a branch that can be reached. Example:

1git prune

Source :  https://www.siteground.com/tutorials/git/commands/

Post Author: Study