Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

28 February 2017

Git | Github | Summary and get started

Quick setup

  • Install git, sudo apt-get install git
  • Create Github account
  • In terminal, generate SSH key cd ~/.ssh && ssh-keygen leave passphrase empty, just press enter until the key is created
  • While still in ssh directory, cat id_rsa.pub and copy the entire key
  • Go to your Github setting, SSH and add SSH. paste the key in the key field. Give it a proper name and save
  • Go back to terminal, setup username and email on git git config --global user.name "john" and git config --global user.email "john.doe@gmail.com" Remember the username and email address muss be the same as the ones used for Github account
  • Go back to Github, create a new repository.
  • Now go to the folder of your application. cd /path/of/your/application and run these command
  • git init
  • git add -A
  • git commit -m "any message e.g. 'my first commit'"
  • Add your ssh URL or copy paste from your Github repository page git remote add origin ssh://login@IP/path/to/repository
  • git push -u origin master

21 February 2017

Git | Github | Basic Knowledge

  • If we work on feature of an application, we have to be careful that changes that have been made aren't going to break the application. In Git, we have a master branch where the application is stored in production and we can also have a feature branch to work on a feature in development. Any changes made in this branch will not affect our master branch. this allows many developers to work on different features of an application without touching the application in production. 
  • to create a new branch type in this command in the application directory: git checkout -b branchName
  • To check in what branch you are currently in and to see all existing branches in git: git branch (your current location will be marked with asterisk)
  • To go back to master branch: git checkout master
  • When creating new branch, keep in mind that you cannot "git push" from your new branch. You'll have first to create a new branch in your github. You can use this one command line to set up a new branch and pushing all at once: git push --set-upstream origin yourNewBranch
  • If you're using Rubymine and you want to merge your branches. I recommend to use merging function from Rubymine interface, not from terminal. I often have merging issues wenn merging from terminal. 
  • Merging is done from the master-branch otherwise changes wont be merge to master and you'll get a message "branch is already up to date.

Useful Command Line

  • To delete a branch (if you're in master branch): git branch - d branchName
  • To delete a folder in git but not in local git rm -r --cached myFolder