Skip to content

buddhasaikia/gitCommands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

Git Commands

Git commands I use to streamline my daily job.

Git workflow - Atlassian Git Flow Tutorial

Setup User Credentials in Git Console (for all repositories)

git config --global user.email "you@example.com"
git config --global user.name "your name"

Setup User Credentials in Git Console (for single repository)

git config user.email "you@example.com"
git config user.name "your name"

Check Username & Email

git config --list
git config user.name
git config user.email

Show Git Remote Repository

git remote -v

Create Existing Project to Bitbucket for the First Time

git init
git add --all
git commit -m "initial commit"
git remote add origin https://username@your.bitbucket.domain:7999/yourproject/repo.git
git push -u origin master

Change Remote URL

git remote set-url origin https://username@your.bitbucket.domain:7999/yourproject/repo.git

Switch to New Remote Branch & Checkout

git fetch && git checkout development

Git tag

To create a simple (lightweight) tag

git tag v1.0.0

To create an annotated tag

git tag -a v1.0.0 -m "Release version 1.0.0"

To push the tag to GitHub

git push origin v1.0.0

To push all tags at once

git push origin --tags

Daily Commit Workflow

git add .
git commit -m "your message"
git push origin development
git tag v1.0.0_20170503 # or git tag -a v1.0.0_20180423 -m "tag for release v1.0.0"
git push origin --tags

Create & Switch Branch

git checkout -b <branch_name>

Publish Local Branch to Remote

git push -u origin <branch_name>

Merge Branch & Push to Origin

git checkout development
git merge firebase_crash_reporting
git add .
git commit -m "added firebase_crash_reporting"
git push origin development

Revert All Local Uncommitted Changes (should be executed in repo root)

git checkout .

Configure Git Mergetool

git config --global merge.tool meld
git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe" # path to meld here

Open Git Merge Tool

git mergetool

Remember to Commit the Merge

git commit -am 'merged from several branches'

Delete Git Tag

git tag -d <tag_name>

List All Tags

git tag

Create Git Repository

git init

Update Remote URL

git remote set-url origin git://new.url.here

Show Remote URL

git remote show origin

Show Last Commit

git log -1
git show

Update Local Repository, Overwrite All

git fetch --all
git pull origin master

List All Repository Tags

git tag

Get List of Conflicted Files

git diff --name-only --diff-filter=U

Check Whether the Branch You Are Tracking is Ahead, Behind or Has Diverged

git status -uno

Display Tags

git tag
git show <tagname>

Delete Tag

git tag -d <tagname>

Delete Tag from Remote

git push origin -d <tagname>

Checkout a Tag

git checkout -b <branch name> <tag name>

Track Remote Branch

git checkout --track origin/dev

Show Last Commit Message

git log -1

Fatal: Refuse to Merge Unrelated Histories on Every Especially First Pull Request After Remotely Adding a Git Repo

git pull origin branchname --allow-unrelated-histories

Push New Local Repository to Remote and Track

git checkout -b feature_branch_name
git push -u origin feature_branch_name

Change Last Commit Message (local)

git commit --amend

Undo git add .

git reset

Undo a Conflict Merge

git merge --abort

Git Reset/Undo Last 2 Commits

git reset --hard head~2
git push origin head -f

About

Git command I use to streamline my daily job

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published