Your Vision Our Goal
+91 8888860970 info@upstacksolutions.com

Deploy code on server using GIT or Bitbucket

The purpose of Git is to manage a project, or a set of files, as they change over time. Git stores this information in a data structure called a repository. Git is a revision control system, a tool to manage your source code history. GitHub is a hosting service for Git repositories. So they are not the same thing: Git is the tool, GitHub is the service for projects that use Git.

Follow below process to create repository on Git and commit the code. So first create your accout on github.com or bitbucket

If you have already existing project and want to commit it on GIT or Bitbucket,

  • Login to Github account, create new repository.
  • Switch to your code using command prompt
    • cd /var/www/html/yourProject
  • Connect your existing repository to Bitbucket
    • Initialize git using Below command
      • git init
    • Connect your existing repository to Bitbucket/GIT. you will get origin when you access your repository in Bitbucket/Git
      • git remote add origin https://codeguruPlenarea@bitbucket.org/codeguruPlenarea/laravelsamplecode.git
    • Now Push your code to repository using below commands,
      • git add *.*
      • git commit -m “your commit message”
      • git push -u origin master

We usually follow below deployoment process,

  1. Always checkout to master branch
    • git checkout master
  2. Pull master code evenif you did not made any changes as other team members may worked on it
    • git pull origin master
  3. Create new branch before you start new work or new functionality
    • git checkout -b newBranchName
  4. Add Changed file to git
    • git add file1.php file2php
  5. Commit changes to your branch
    • git commit -m “first commit”
  6. Push your changes to your branch
    • git push origin newBranchName
  7. Make sure all your changes are working. If yes then merge your branch to master branch. Hope your have committed your changes to your branch. then switch to master branch and pull master branch.
    • git checkout master
    • git pull origin master
  8. Go to your branch and rebase your branch with master. This way your branch will have updated code of master along with your code.
    • git checkout newBranchName
    • git rebase master
  9. If you get any conflict while rebasing then resolved it using below steps else got to step 10
    • git add file1.php(assuming file1.php has conflicts and you fixed it)
    • git rebase –continue
    • git push -f origin newBranchName
  10. Now you are ready to merge your code with master
    • git checkout master
    • git merge –no-ff newBranchName
    • git push origin master

Leave a Reply

Your email address will not be published. Required fields are marked *