MCNi Wiki : Updating custom module code for git n00bs

So you need to tweak some module code on the Bombplates system, eh? Maybe update a module CSS file or swap out an icon or something? Alright. Let's do this thing.

-------------------------

STEP 1: go to the codebase

$ ssh MYUSERNAME@DEVSERVER.bombplates.com

If you don't know your user name, talk to a sysadmin

Then navigate to the modules directory

$ cd /var/www/html/sites/all/modules

-------------------------

STEP 2: Stash local changes

$ git status

If it displays...

# On branch XXXX nothing to commit, working directory clean

Move on to step 3.

If XXXX is not "develop" or "master", commit your changes

If git status said...

...
# Changes not staged for commit
...
#    deleted: SOME
#    deleted: FILES
#    deleted: FOLDER/

There are local file deletions to add to git

$ sudo git rm -rf SOME FILES FOLDER

Then commit the rest of your changes

$ sudo git add .
$ sudo git commit -m 'tkt#YYYY - description of what these changes are'

If XXXX is "develop" or "master", stash those changes somewhere else for later review

$ mkdir ~/YYYY-ticket-description/
$ git diff > ~/YYYY-ticket-description/YYYY.diff

Find any untracked files

$ git status
...
# Untracked files:
...
#    SOME.FILE
#    FOLDER/

And move them.

$ mv SOME.FILE ~/YYYY-ticket-description/
$ mv FOLDER ~/YYYY-ticket-description/

Then revert back to the baseline

$ sudo git checkout .

And tell a developer about ~/YYYY-ticket-description so that they can roll the code into the codebase correctly

-------------------------

STEP 3: Start your code changes from the master branch

$ sudo git checkout master

If it displays...

# On branch XXXX nothing to commit, working directory clean

Skip to step 4

If it displays...

# On branch master
# Your branch is ahead of 'origin/master' by Y commits, and can be fast-forwarded.
#   (use "git push" to publish your local commits)

Push your local changes

$ sudo git push origin master

If it displays

# On branch master
# Your branch is behind 'origin/master' by Y commits.
#   (use "git pull" to update your local branch)

Pull the remote changes

$ sudo git pull origin master

-------------------------

STEP 4: Fork your branch

$ sudo git checkout -b TYPE/TKT-DESC

Where TYPE is hotfix or feature, TKT is the ticket number, and DESC is a brief description of the changes (with no spaces; use underscores or dashes)

-------------------------

STEP 5: Make your changes

Commit your changes frequently

$ sudo git add .
$ sudo git commit -m 'tkt#TKT description of changes'

Once all your changes are completed and committed, push them out.

$ sudo git push origin TYPE/TKT-DESC

-------------------------

STEP 6: Merge your changes into the development branch

$ sudo git checkout develop
$ sudo git pull origin develop
$ sudo git merge origin/TYPE/TKT-DESC
$ sudo git push origin develop

-------------------------

STEP 7: Test & have other people review your changes

If you need to revise your code changes...

$ sudo git checkout TYPE/TKT-DESC

Then repeat steps 5 and 6 as needed

-------------------------

STEP 8: Deploy to live

This step may be performed by someone else.

$ sudo git checkout master
$ sudo git pull origin master
$ sudo git merge origin/TYPE/TKT-DESC
$ sudo git push origin master
$ sudo git checkout develop
$ exit
$ ssh MYUSER@BANDSX.bombplates.com
$ cd /var/www/html/sites/all/modules
$ sudo git pull origin master