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 [27/04/2020 14:57]
andrew [Backing out changes]
rb:git-cheatsheet [28/05/2020 13:58] (current)
andrew [git init]
Line 12: Line 12:
  
  
 +
 +===== Add Git Branch to PS1 prompt =====
 +
 +Thanks Dharmesh for the info! You know who you are!
 +
 +In your ''​.bash_profile''​ in your home directory, add:-
 +
 +<​code>​
 +git_branch() {
 +  git branch 2> /dev/null | sed -e '/​^[^*]/​d'​ -e 's/* \(.*\)/ (\1)/'
 +}
 +
 +export PS1="​\u@\h \W\[\033[32m\]\$(git_branch)\[\033[00m\]$ "
 +</​code>​
 +
 +This gives:​- ​
 +
 +
 +laptop economy-7 <fc #​00ff00>​(abc-123)</​fc>​ $
  
 ===== Starting a new repo ===== ===== Starting a new repo =====
Line 58: Line 77:
   Initialised empty Git repository in /​home/​andrew/​ansible/​testplays/​cis-awsLinux2/​.git/​   Initialised empty Git repository in /​home/​andrew/​ansible/​testplays/​cis-awsLinux2/​.git/​
  
 +==== git clone ====
 +
 +Pulls a repo down from ''<​URL>''​
  
 +  git clone <url>
  
 ==== git branch (create and delete) ==== ==== git branch (create and delete) ====

rb/git-cheatsheet.1587999450.txt.gz · Last modified: 27/04/2020 14:57 by andrew