Paul
Paul

Reputation: 169

Pushing from local to remote repositories using GIT

Using GIT, I made some changes in my local repository. Now I want to "upload" changes to remote repository. Does this mean that I will have to create new branch every time to do so? Does this mean, that code in remote depository (which is also accessible via github) must be of "production" quality.

Upvotes: 0

Views: 66

Answers (2)

U r s u s
U r s u s

Reputation: 6968

Absolutely not, you don't have to. However it is not advisable to push directly to master. The point of version control systems like Git is that you can create different branches and work on them separately and to merge to your main branch (master) only when you're ready to do so.

Imaging this case

You’ve decided that you’re going to work on issue #53 in whatever issue-tracking system your company uses. To create a branch and switch to it at the same time, you can run the git checkout command with the -b switch: git checkout -b iss53. You work on your web site and do some commits. Now you get the call that there is an issue with the web site, and you need to fix it immediately. With Git, you don’t have to deploy your fix along with the iss53 changes you’ve made, and you don’t have to put a lot of effort into reverting those changes before you can work on applying your fix to what is in production. All you have to do is switch back to your master branch: git checkout master. Next, you have a hotfix to make. Let’s create a hotfix branch on which to work until it’s completed: git checkout -b hotfix. You can run your tests, make sure the hotfix is what you want, and merge it back into your master branch to deploy to production. You do this with the git merge command: git checkout master and git merge hotfix. After your super-important fix is deployed, you’re ready to switch back to the work you were doing before you were interrupted.

The quote above is from this great git resource. It goes in a lot of details and the workflow I'm linking to is what you're after.

Upvotes: 1

joran
joran

Reputation: 2883

Git or github do not require a new branch in order for you to push your changes to a remote repository or that the code in the remote repository to be "production" ready.

You may have a workflow that says that you shall do all the work in different (feature, hotfix..) branches and only merge with a merge commit, but that is up to you and your coworkers.

Upvotes: 0

Related Questions