Make you DB scripts available via GitHub
Storing your database scripts on-line is one way to
ensure that they are always available (as long as you have
Internet access). One way to achieve this is to use a code repository such as GitHub.
In this post I will look at one way in which you can store your database scripts using Github.
Create a Github account if you do not already have one.
Install the appropriate git client for your OS (In this post I will be using the git shell on Windows).
1. Create a new repository in GitHub and make a note of the URL (https://github.com/youruser/ myrepo.git)
2. Open a git shell on your local PC and navigate to the folder which contains your DB scripts.
3. Initialise the directory by typing the following command:
git init
3a. If you initialise the repo with a .gitignore
and a README.md you should do a git pull {url from step 1} to ensure you
don't commit files to source that you want to ignore.
4. Locally, add and commit what you want in your initial repo. For everything type:
git add .
git commit -m 'Initial commit comment'
5. To attach your remote repo with the name 'origin' (like cloning would do)
git remote add origin "https://github.com/youruser/ myrepo.git"
6. Execute git pull origin master to pull the remote branch so that they are in sync.
git pull origin master
7. To push up your master branch (change master to something else for a different branch):
git push origin master
Once you have uploaded your scripts you will want to push any changes that you make to the local copy of the scripts to GitHub.
Push changes to a repository
1. Open git shell and cd to source directory
2. To get the current status type
git status
3. Add the changes (i.e. new files etc.)
git add name_of_new_script. sql
4. Commit changes with comment
git commit -m “Add name_of_new_script.sql”
5. Either add the remote origin or check its already set up.
git remote add origin https://github.com/youruser/myrepo.git
And then double check to make sure it knows:
git remote -v
6. If you have made changes in the GIT account (i.e. added readme file) then you need to pull before you can push
git pull origin master
7. push change
Notes -
You can read and download the entire Pro Git e-book, written by Scott Chacon and Ben Straub and published by Apress, from here.
http://www.git-scm.com/book/en/v2
There is also excellent documentation available on the GitHub site.
Six Revisions - Top 10 Git Tutorials for Beginners
No comments:
Post a Comment