My Custom Git Cheet Sheet Command

git identity

- git config --global user.name "Addhe Warman"
- git config --global user.email "addhe.warman@gmail.com"

git editor

- git config --global core.editor vim

git diff tool

- git config --global merge.tool vimdiff

git check settings

- git config --list

git help

- git help
- man git

git initial a repository in existing directory

$ git init
$ git add sample.txt
$ git add README
$ git commit -m 'first initial project versioning'

git cloning existing repository

$ git clone https://github.com/addhewarman/docker-locust


$ git clone git@github.com:addhewarman/docker-locust.git

git check status of your file changes

$ git status

git tracking new files

$ git add YOUR_FILE


$ git add YOUR_FILE_1 YOUR_FILE_2

git how you commit your changes


$ git status


$ git diff


$ git add YOUR_MODIF_FILE


$ git commit -m 'i have updated my file'


$ git log


$ git show SHA_NUM

git revert your changes

$ git checkout YOUR_MODIF_FILE

git revert one commit

$ git reset HEAD~1

or

$ git revert HEAD

git ignore file

$ vim .gitignore

git check your ignore file


$ cat .gitignore
*.log
*.[abc]
*.~
*.a
doc/*.txt
build/rake/*
composer/dump/*

git compare your changes


$ git diff


$ git diff --cached

git compare staged changes to your last commit

$ git diff --staged

git commit your changes

$ git commit -m '
i made this cheatsheet as simple and posible
as clear as clean water and 5 years old kid can
learn and read it
'


$ git commit -a -m '
add -a will add everything without have to add
or using git add one by one
'

git remove file that you already add

$ git rm YOUR_FILE


$ git rm *~


$ git rm log/*.log

git moving files

$ git mv file_from file_to

git show commit history

$ git log


$ git log -p -2

git series of summarizing option

$ git log --stat

git log output to formats other than default (one liner)

$ git log --pretty=oneline

git log output to your own format

$ git log --pretty=format:"%h - %an, %ar: %s"

git limit log output

$ git log --since=12.weeks

git log commit by awan in december 2014 to january 2015

$ git --pretty="%h:%s" --author=awan --since="2014-12-01" --before="2015-01-28"

git log pretty format with ASCII graph visual of your branch and merge

$ git log --pretty-format:"%h %s" --graph

git commit forget one file to commit

$ git commit -m 'i commit this and i forget one file'
$ git add file_kelupaan
$ git commit --amend

git command to revert one file from list of your git add

case : dayummm i git add everything, i should not add them all this cubbysmart.txt should not in the list


awan@google:~/django# git add .
awan@google:~/django# git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
# new file: awan.txt
# new file: cubbysmart.txt
# new file: encrypt.py
# new file: index.py
# new file: master_code.py
#
awan@google:~/django# git reset HEAD cubbysmart.txt
awan@google:~/django# git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
# new file: awan.txt
# new file: encrypt.py
# new file: index.py
# new file: master_code.py
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# cubbysmart.txt
awan@google:~/django#

git unmodifying a modified file

$ git checkout your_modified_file.py

git showing your remotes

$ git remote


$ git remote -v

git add remote repository

$ git remote add awan_cloud git://github.com/awan/cloudofme.git


awan@google:~/django# git remote
origin
awan@google:~/django# git remote -v
origin ssh://534dda7f5004461b4d0000f8@django-addhewarman.rhcloud.com/~/git/django.git/ (fetch)
origin ssh://534dda7f5004461b4d0000f8@django-addhewarman.rhcloud.com/~/git/django.git/ (push)
awan@google:~/django# git remote add awan_cloud git://github.com/awan/cloudofme.git
awan@google:~/django# git remote -v
awan_cloud git://github.com/awan/cloudofme.git (fetch)
awan_cloud git://github.com/awan/cloudofme.git (push)
origin ssh://534dda7f5004461b4d0000f8@django-addhewarman.rhcloud.com/~/git/django.git/ (fetch)
origin ssh://534dda7f5004461b4d0000f8@django-addhewarman.rhcloud.com/~/git/django.git/ (push)

git get data from remote projects

$ git fetch your_remote


$ git fetch awan_cloud

git push to your remote

$ git push origin remote


$ git push origin awan_cloud

git inspecting a remote

$ git remote show origin


$ git remote show awan_cloud

git remove and rename remotes

$ git remote rename awan_cloud cloud_aws


$ git remote


$ git remote rm cloud_aws

git tag your revision

$ git tag


$ git tag -a your_tag_name -m 'my first tag' your_sha_revision_id


awan@google:~/django# git tag -a my_tag -m 'tset tag' 22d9cd99b2184967033fd14b1be8cd5c88a1d037
awan@google:~/django# git tag -l
my_tag
awan@google:~/django# git show my_tag
tag my_tag
Tagger: Awan
Date: Sun Aug 30 23:09:26 2015 +0700

tset tag

commit 22d9cd99b2184967033fd14b1be8cd5c88a1d037
Author: Awan
Date: Wed Apr 16 08:17:40 2014 +0700

update code

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..70166b0
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+#addhe warman django project
awan@google:~/django#


git sharing tag

$ git push origin my_tag

git alias

$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status
$ git config --global alias.unstage 'reset HEAD --'
$ git config --global alias.last 'log -1 HEAD'

git check your current branch

$ git branch

git create a branch

$ git checkout -b MY_NEW_BRANCH

git push changes to branch

$ git push origin MY_NEW_BRANCH

git pull from branch

$ git pull origin MY_NEW_BRANCH

git change back to master branch

$ git checkout master

git merge branch to master

$ git checkout master
$ git merge MY_NEW_BRANCH

—————— continue to part 2

Advertisements

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