Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rb:git-cheatsheet [11/07/2019 11:25]
andrew [git branch]
rb:git-cheatsheet [18/09/2019 16:41] (current)
andrew [git config]
Line 21: Line 21:
   $ git config --global user.email me@mycomp.co.uk   $ git config --global user.email me@mycomp.co.uk
   $ git config --global user.name Real Name   $ git config --global user.name Real Name
 +
 +You can see the current settings in force with:-
 +
 +<​code>​
 +$ git config --list
 +core.excludesfile=~/​.gitignore
 +core.legacyheaders=false
 +...edited...
 +color.ui=auto
 +color.interactive=auto
 +alias.s=status
 +alias.a=!git add . && git status
 +</​code>​
 +
 +Note this also shows aliases which are useful shorthand:-
 +
 +<​code>​
 +$ git s
 +On branch master
 +Your branch is up to date with '​github/​master'​.
 +
 +Untracked files:
 +  (use "git add <​file>​..."​ to include in what will be committed)
 +
 + fullstack-expt/​.terraform/​
 +
 +nothing added to commit but untracked files present (use "git add" to track)
 +</​code>​
  
  
Line 32: Line 60:
  
  
-==== git branch ====+==== git branch ​(create and delete) ​====
  
 === Adding and listing branches === === Adding and listing branches ===
Line 38: Line 66:
  
 | git branch <​name>​ | create new branch | | git branch <​name>​ | create new branch |
-| git branch ​-b  <​name>​ | create new branch and checkout |+| git checkout ​-b  <​name>​ | create new branch and checkout |
 | git branch | List branches | | git branch | List branches |
 | git branch -a | List all branches, local and remote | | git branch -a | List all branches, local and remote |
Line 46: Line 74:
  
  
-| git branch -d <​branch>​ | safe delete branch id merged ok | +''​git branch -d <​branch>​'' ​| safe delete branch id merged ok | 
-| git branch -D <​branch>​ | delete *without* warnings | +''​git branch -D <​branch>​'' ​| delete *without* warnings | 
-| git push origin --delete <​branch>​ | push deletes to remote master |+''​git push origin --delete <​branch>​'' ​| push deletes to remote master |
  
  
Line 54: Line 82:
 ==== git checkout ==== ==== git checkout ====
  
 +Create a new branch and checkout
 +  $ git checkout -b ajs/​newBranch
 +
 +Switch to different branch
   $ git checkout ajs/​emptyDirWarning   $ git checkout ajs/​emptyDirWarning
   Switched to branch '​ajs/​emptyDirWarning'​   Switched to branch '​ajs/​emptyDirWarning'​
-  ​+ 
 +And back to master branch  ​
   $ git checkout master   $ git checkout master
   Switched to branch '​master'​   Switched to branch '​master'​
   Your branch is up-to-date with '​origin/​master'​.   Your branch is up-to-date with '​origin/​master'​.
  
-Switch to different branch+
  
 ==== git add ==== ==== git add ====
Line 213: Line 246:
 </​code>​ </​code>​
  
 +
 +==== git tag ====
 +
 +Create a release and add a tag to it, this creates a new HEAD from master which cannot be modified further.
 +
 +<​code>​
 +$ git tag -a 0.1.1 -m "​Updated Tags"
 +$ git push --tags
 +
 +...work...
 +
 +$ git tag -a 1.0.0 -m "​Updated Tags, ready for production."​
 +$ git push --tags
 +
 +$ git tag -n
 +1.0.0           ​Updated Tags ready for production.
 +v0.1.0 ​         Merge pull request #9 from JSainsburyPLC/​ajs/​TagAddition
 +v0.1.1 ​         Updated Tags
 +</​code>​
  
 ===== Adding some new files to existing repo ===== ===== Adding some new files to existing repo =====

rb/git-cheatsheet.1562840730.txt.gz · Last modified: 11/07/2019 11:25 by andrew