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

No comments:

Post a Comment