Tuesday, August 23, 2011

Collaborative Writing with Git

Starting a new repository using github:

1) Go to github.com, create an account and start a new remote repository. We will create the project name HPCA2012.

2) Go to the directory of your project and start a local git repository:
>>cd HPCA2012
>>git init
>>git add .
>>git commit -m "My first commit"

3) Now add the remote repository as the origin:
>>git remote add origin git@github.com:gbezerra/HPCA2012

4) Push the changes to the remote repository:
>>git push -u origin master

Contributing to a shared repository:

1) create a local copy of the repository using git clone:
>> mkdir HPCA2012
>> cd HPCA2012
>> git clone git@github.com:gbezerra/HPCA2012 .

2) Add the remote repository to your list of remotes. Its shortcut name will be origin.
>> git remote add origin git@github.com:gbezerra/HPCA2012
Now you can use the name "origin" to refer to the remote repo.

3) Modify the files, in this case file hpca2012.tex, and commit your changes.
git commit -a -m "your commit message"

4) Merge and solve conflicts:
>>git pull

5) Share:
>> git push origin master

Whenever you want to update your local repo with the latest changes just use
>>git pull
To check the status of your repository use
>> git status
Once your repository is setup you'll only need steps 3 to 5 in your workflow.

Good luck!

Tuesday, May 10, 2011

How to add a startup script on Debian linux

1) create your script (myscript) and add it to /etc/init.d/

2) make it executable: chmod 755 myscript

3) add the appropriate symbolic links: update-rc.d myscript defaults

If you want to remove the script from startup do the following:

$ update-rc.d -f myscript remove

Then remove the script from the init.d directory.

Reference

Monday, May 9, 2011

How to change username in Ubuntu

In order to change your old username (old_user) to a new one (new_user) do the following:
(I tried this logged in as a different user)

$ usermod -l new_user old_user

Now change the name of the home directories:

$ mv /home/old_user /home/new_user

Next, edit the /etc/passwd file, look for new_user and change the home directory to the new one.

Now, reboot your computer.

Wednesday, January 26, 2011

MySQL

How to rename a database:

1) Find the directory where MySQL stores the database information:
$ mysqladmin -u gbezerra -p variables | grep datadir

2) Change the directory name of the database
$ sudo mv <datadir>/<old_name> <datadir>/<new_name>

Thursday, January 20, 2011

Git useful commands

Pulling changes

Pulling updates from master:
$ git pull
or
$ git pull origin master


Pull updates from arbitrary remote repository:
$ git pull repository.name.git HEAD

Pushing changes


Committing and pushing changes to remote branch (example, tlb branch)
$ git add filename
$ git commit
$ git push origin tlb

Merging


$



Commit and reverting files



Commit all tracked files:
$ git commit -a


Revert a single file:
$ git checkout filename

If the filename is the same as the branch name that could be a problem. In this case type:
$ git checkout --filename

Undo uncommitted changes for the whole repository:
$ git reset --hard HEAD


Adding a file to a previous commit. Suppose that you forgot to include a file in your commit. You can include this file by first adding it and then using the amend option.
$ git add filename
$ git commit --amend -C HEAD
The -C option will allow you to reuse the old message from the HEAD commit.




Adding and Tracking files

Staging all tracked files
$ git add -u

Untrack a file and remove it from the directory tree:
$ git rm filename

Untrack a file without removing it from the directory tree:
$ git rm --cached filename


List tracked files, or check if a single file is tracked:
$ git ls-files
$ git ls-files filename

Branches

List all branches:
$ git branch -a


Create a new branch:
$ git checkout -b branch_name

Create a new branch from an existing remote branch:
$ git checkout -b newbranch origin/branch_name

Change branches:
$ git checkout branch_name

Delete a branch
$ git branch -D <branch_name>


Rename a branch:
$ git branch -m <old_name> <new_name>

Diff between two branches:
$ git diff branch1..branch2

Merging

Configurations

Ignoring certain file extensions, names, or directories. To do we need to edit the .gitignore file. Example of a .gitignore file:
*.swp
*.pyc
log/