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
systems:git_setup_and_configuration [2017/09/26 12:20]
smayr [Setup Local Repo to Push to BitBucket Repo using SourceTree]
systems:git_setup_and_configuration [2018/06/18 14:39] (current)
smayr [Synchronize Changes]
Line 208: Line 208:
   $ git pull                       # Downloads bookmark history and incorporates changes     $ git pull                       # Downloads bookmark history and incorporates changes  
      
 +**Fetch vs. Pull:** Do a ''git fetch'' at any time to update your remote-tracking branches under ''refs/remotes/<remote>/''. This operation never changes any of your own local branches under ''refs/heads'' A ''git pull'' is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.
 +
 +Basically a ''git pull'' is a ''git fetch'' + ''git merge FETCH_HEAD'', but the latter allows time to review changes before the merge (the former does the merge automatically, which sometimes can be disastrous). 
 +
 +Therefore, instead of a ''git pull'', using ''git fetch; git reset --hard origin/master'' is a safe method to add to your workflow. It eliminates local changes, keeps you up to date with master, but ensure new changes do not get pulled in on top on current changes and make a mess. It is a safer practice. Just be sure to add/commit/stash any work-in-progress first.
 +
 +See: 
 +  * [[https://stackoverflow.com/questions/292357/what-is-the-difference-between-git-pull-and-git-fetch|Difference between git pull and git fetch]]
 +  * [[https://longair.net/blog/2009/04/16/git-fetch-and-merge/|Git: Fetch and Merge, Don't Pull]]
 +
 +Get any changes in the remote branch since the last pull:
 +  $ git fetch
 +  $ git diff ...origin (or $ git diff origin/master)
 === Merge or Rebase === === Merge or Rebase ===
 Merge the ''master'' to the ''feature'' branch: Merge the ''master'' to the ''feature'' branch:
Line 259: Line 272:
 == Setup Local Repo to Push to BitBucket Repo using SourceTree == == Setup Local Repo to Push to BitBucket Repo using SourceTree ==
  
-  # On the main application options (Tools > Options > Authentication > Accounts), set the authentication to use Preferred Protocol ''SSH'' instead of ''HTTPS''+Install SourceTree and add BitBucket account: 
-  # On the local repo, go to Settings and change remote origin address from ''https'' (ie: ''https://[username:password]@bitbucket.org/[username]/[repo].git'') to ''ssh'' (ie: ''git@bitbucket.org:[user]/[repo].git''). You will find these addresses at the top of your BitBucket repository page.+  # On the SourceTree application options (Tools > Options > Authentication > Accounts), add a BitBucket account.  
 + Set the authentication to use Preferred Protocol ''SSH'' instead of ''HTTPS''
 +  # On the SourceTree local repo, go to Settings and change remote origin address from ''https'' (ie: ''https://[username:password]@bitbucket.org/[username]/[repo].git'') to ''ssh'' (ie: ''git@bitbucket.org:[user]/[repo].git''). You will find these addresses at the top of your BitBucket repository page. 
 + 
 +Create an SSH key 
 +  # On SourceTree, select Tools > Create or Import SSH Keys. 
 +  # In PuTTY Key Generator, generate a 2048-bit SSH-2 RSA key, then: 
 +    * Copy the public key.   
 +    * Save the private key locally. 
 +    * Save the public key. 
 + 
 +Install Private Key on Pageant (PuTTY Authentication Agent) 
 +  # Run Pageant or open from icon tray. 
 +  # Add private SSH key, by clicking on Add Key button, then entering the passphrase. 
 + 
 +Add Public Key to BitBucket 
 +  # In SourceTree, open the PuTTY Key Generator from Tools > Create or Import SSH Keys. 
 +Click Load and select the private key file. 
 +  # Copy the public key. 
 +  # On BitBucket Account Settings (user avatar), select SSH keys, then Add Key. 
 +  # Enter label "Default Public Key"
 +  # Paste public key to Key field, and save. 
 + 
 +=== References === 
 +  * [[https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html|Bitbucket: Set Up an SSH Key]] 
 + 
 +== Git Flow == 
 +Organizing your repository to use git flow. 
 +{{ :systems:git-model_2x.png?600 |}} 
 +Author: Vincent Driessen | 
 +Original blog post: http://nvie.com/posts/a-succesful-git-branching-model | 
 +License: Creative Commons BY-SA
  
 +  * Use Semantic Versioning: [[https://semver.org]]
 +  * [[https://nvie.com/posts/a-successful-git-branching-model/|Successful GIT branching model]]
 +  * [[https://www.youtube.com/watch?v=z53JJ7P78Vc|Git Flow Tutorial]]
 +  * [[https://blog.sourcetreeapp.com/2012/08/01/smart-branching-with-sourcetree-and-git-flow/|Smart Branching with SourceTree and Git Flow]]
  
 == References == == References ==