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 [18/09/2019 15:41]
andrew [git config]
rb:git-cheatsheet [27/04/2020 14:57] (current)
andrew [Backing out changes]
Line 135: Line 135:
 Adds a remote named <​name>​ for the repository at <​url>​. ​ Convention seems to be using ''​origin'',​ but you could use a more descriptive name, eg. codeCommit or gitHub. I think this would allow you to set two remotes and push to either or. Adds a remote named <​name>​ for the repository at <​url>​. ​ Convention seems to be using ''​origin'',​ but you could use a more descriptive name, eg. codeCommit or gitHub. I think this would allow you to set two remotes and push to either or.
  
-''​git remote add [-t <​branch>​] [-m <​master>​] [-f] [--[no-]tags] [--mirror=<​fetch|push>​] <​name>​ <​url>''​+Setting two remotes seems a way to move a repo from one repository host to another (eg. Github to AWS Code Commit).
  
-  $ git remote add origin https://​github.com/​user/​RepoName.git 
-  or 
-  $ git remote add codeCommit https://​git-codecommit.eu-west-1.amazonaws.com/​v1/​repos/​RepoName 
  
 +''​git remote add [-t <​branch>​] [-m <​master>​] [-f] [--[no-]tags] [--mirror=<​fetch|push>​] <​name>​ <​url>''​
 +
 +<code git>
 +$ git remote add origin https://​github.com/​user/​RepoName.git
 +or
 +$ git remote add codeCommit https://​git-codecommit.eu-west-1.amazonaws.com/​v1/​repos/​RepoName
 +</​code>​
  
 ==== git remote delete ==== ==== git remote delete ====
Line 171: Line 175:
  
  
-AWS CodeCommit *REQUIRES* a "​helper",​ see [[rb:​aws-cli#​roles_with_codecommit|Amazon Web Services CLI]]+AWS CodeCommit *REQUIRES* a "​helper",​ see [[aws:​aws-cli#​roles_with_codecommit|Amazon Web Services CLI]]
  
  
Line 204: Line 208:
  
  
 +Note, ''​git fetch''​ will get updates from the origin, but will not merge with any local changes. ''​git pull''​ is the same as ''​git fetch''​ followed by a ''​git merge''​. ''​git getch''​ will never change your local copy or branch, but ''​git pull''​ will update your local branch to it's remote version, which you may not want. 
 +
 +
 +==== git fetch ====
 +
 +''​git fetch''​ will get updates from the origin, but will not merge with any local changes.
  
 ==== git log ==== ==== git log ====
Line 475: Line 485:
  
   $ git checkout 3d83c24b89d7b27aecf99fecef54982d3ecf0620^ -- ansible_id_rsa ​   $ git checkout 3d83c24b89d7b27aecf99fecef54982d3ecf0620^ -- ansible_id_rsa ​
 +
 +
 +
 +===== Backing out changes =====
 +
 +Problem:- On local master branch by mistake and attempt to merger local branch to it, meant to merge one local branch with another.
 +
 +Solution:- running ''​git merge <​branchname>''​ whilst master is checked out merged changes to the wrong place, to revert master back to as it was, I ran ''​git reset --hard origin/​master''​
 +
  
  

rb/git-cheatsheet.1568821296.txt.gz · Last modified: 18/09/2019 15:41 by andrew