Git Workflow

Tags:
Document Information
Document ID: 
app2011-019

In a recent post I described setting up a project's Git repository and cloning the project from the repository so you can make changes to the project.  In this post I will describe a recommended workflow for modifying a Git based project.

Assuming you have already created or have access to an existing git project the first step is to clone (git clone file:////SERVER3/DevelopmentDocs/gitRepository/<project name>), where <project name> is the name of the project and will be the output folder name.

Git best practices recommend working on a branch while making edits or changes to a project.  Working on a branch provides a temporary workspace where you can modify the applications files as much as you like withouth having to worry about overriting the applications core file.  To create a branch type "git checkout -b <branch name>", where <branch name> an be any name you like.

Make changes to the files that need modification.

Type "git add <file name(s)> or git add <folder names>" and press Enter to add the changes to the repository.

Type "git checkout master" and press Enter.  This switches you back to the master branch of the project.

Type "git merge <branch name> and press enter.

If there are no merge conflicts then you can type "git push origin master" and press Enter.  This will commit your changes to the repository.

You might need to enter "git pull" at the command line before starting the merge proeccss if someone else in the oginazation has altered files in the repository.

If there are merge conflicts Git will display a message(s) about the files where the conflicts occur.

Now you have to push all of you work onto the master version of the project.  You can do this by typing "git push origin master" and pressing Enter.

Finally, if you don't need the branch you were using you can type git branch -d <branch_name> to delete that branch.

Application Documents Description Document ID Posted by Updatesort icon Rating
Creating a Git Repository and Project We've been using Git to manage our Geoportal source code and the Drupal source code to the AZGS Document Repository... app2011-018 averill.cate 01/28/2011 - 12:04pm
0