Git Command(Usage)

# Mergetool
git config –global merge.tool meld

# Difftool
git difftool HEAD

# Pull specific file from branch
git checkout work
git pull origin work
git checkout [branch]
git checkout work — [file]
git add [file]
git commit
git push

# Checkout specific file from specific revision
git checkout [revision] [file_path]

# Omit files not to track
git rm –cached [file]

# View other branch’s file
git show branch_name:[file]

# Remove branch
git branch -D [branch]

# Mergetool : Windows Cygwin
git config –global merge.tool meld
git config –global mergetool.meld.path “/cygdrive/c/Program Files (x86)/Meld/Meld.exe”
/*
git config –global mergetool.meld.cmd “/cygdrive/c/Program Files (x86)/Meld/Meld.exe $PWD/$LOCAL $PWD/$BASE $PWD/REMOTE –output
*/

# Config
vi ~/.gitconfig

# Tag : Delete
git tag -d [tag_name]

# Pull to overwrite
git fetch –all
git reset –hard origin/[branch]

#Release  with tag
git tag v1.0
git checkout master
git merge work
git push origin master
git push –tags
git tag

# Delete all history and Re-initialize git repository forcely

Step 1: remove all history

rm -rf .git

Step 2: reconstruct the Git repo with only the current content

git init
git add .
git commit -m “Initial commit”

Step 3: push to GitHub.

git remote add origin [github-uri]
git push -u –force origin master

# Create Patch
git format-patch [Commit ID]
git format-patch -[the number of commits from HEAD]
(Ex. git format-patch -3)

# Apply Patch
git am [A name of patch file]

# Delete Commit History in Remote
git reset –hard HEAD^
git push -f

# Delete Commit History in Remote
git diff older_revision newer_revision
git diff older_revision newer_revision file_path
git diff older_revision newer_revision — file_path

# View Remote Branches
git ls-remote

Advertisements
Git Command(Usage)

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