Git Summary

Git Summary

 

WORKING WITH BRANCHES

//Show all branches, locals & remotes

git branch -a

//Show only locals

git branch

//checkout remote branch

git checkout -b origin/branch_1

//update

git pull origin branch_1

//Branch serverfix set up to track remote branch refs/remotes/origin/serverfix.

//Switched to a new branch “serverfix”Switched”

git checkout -b serverfix origin/serverfix

//Create branch

git checkout -b newbranch

RESET TO MASTER

//Reset to master. Lost all commits

git checkout master

git reset –hard origin/master

VIEW LOGS, FILTER BY BUILD & CHECKOUT COMMIT

//To search the commit log (across all branches) for the given text

git log –all –grep=’Build 0051′

//To search the actual content of commits through a repo’s history, use

git grep ‘Build 0051’ $(git rev-list –all)

//Checkout by commit id

git checkout 2f787bb5c107f25e5576817413c514a9006bb70e

WORKING WITH LOGS/VERSIONS

//Show last day commit

git log -1 –format=%cd

WORKING WITH  BRANCHES & MERGES

//Return to principal branch

git checkout master

//Delete newbranch

git branch -d newbranch

//Push / public a branch to remote server

git push origin <branch>

// Add remote to origin

git remote add origin <server>

//Send changes to remote

git push origin master

MERGE BRANCHES

//update local repository to last commits

git pull

//fusion other branch with the active

git merge <branch>

//mark files to fusion

git add <filename>

//Review changes before fusion

git diff <source_branch> <target_branch>

WORKING WITH TAGS/VERSIONS

//Tagging particular point

git tag -a v1.0 -m ‘Version 1.0’

//Get to local a determinate tag/version

git checkout tags/v1.0

//Same before but creating a new branch

git checkout tags/v1.0 -b NewBranch

//You can go back to another branch (for example master)

git checkout master

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Social media & sharing icons powered by UltimatelySocial