Category : git...

(2 results found)

Reset a git remote (--bare) repo to 'Initial commit'

Sat Aug 6 05:30:09 2011

wipe git remote

I found a situation where I wanted to totally reset a remote repository and although deleting it and then recreating it using --bare usually does the trick, the server set up shared dependances that would have caused more trouble if I had done that. So the only option was to completely reset the repo and effectively wipe clean any past history.

In actual fact it is simpler than it sounds. Create a local repo using git init, add some files using git add * (where you can also replace the * with the particular name of a file/files). Commit the changes, i.e. git commit -m "Initial commit" and then add the remote url using git remote add origin remote_url_here.

Now all you have to do it push to the master branch of your remote to overwrite everything. However, simply using the command git push origin master will most likely fail due to the fact that content already exits. So here's what you do. Use git push --force.

That should give the desired results and you'll find that the existing remote will update and feel much fresher indeed. However, BE WARNED that this deletes everything as you'll see if you run git log on the remote.

Happy committing!

Using Dropbox as a remote for git

Thu Mar 24 04:36:51 2011

dropbox-n-gitSetting up a git remote on Dropbox is great for backing up and sharing projects with other people. Here's how to get started.

Getting a local repository started

First off open a Terminal window and create a project folder. I'm going to make one in my ~/Sites folder of my mac using the command mkdir (make directory) and cd (change directory) inside.

cd ~/Sites/
mkdir project
cd project

Next create a git repository inside the folder project

git init

When you want to add files that are saved in the projects folder to the repository, use the add and commit commands. For example, say you have the file index.html in your project folder, use git add * where * means everything/all, but can be a specific file name such as index.html. Using the command git status will show you if any changes have been made or/and if there are any untracked files that exist in the directory. Right now, no files have been commited to the repository, so the 'index.html' should be displayed. Run the following to commit to the repository:

git commit -a -m "Initial commit"

The -m followed by a message in between " " will be the message that is display in the log/history of changes. After commiting changes, run git log to view the git history.

Creating and "Pushing" to a Remote (i.e. Dropbox)

Now, in the same way we created a directory for the project, we have to also make a directory for the remote branch. I will make one called "Repository" in the root of Dropbox and then make another folder inside that called project.git, for sake of ease.

cd ~/Dropbox
mkdir Repository
cd Repository
mkdir project.git
cd project.git

Now that we're inside project.git, let's create a bare repository

git init --bare

Now, all that's left is to add our Dropbox remote to the repository of our project and push to it. (We'll have to cd back into the local project folder for that)

cd ~/Sites/project
git remote add origin ~/Dropbox/Repository/project.git
git push origin master

Now, if everything went OK, you should be able to run git log from inside ~/Dropbox/Repository/project.git and view the same log as ~/Sites/project.

Pulling from the Dropbox Remote

Let's say that you are now on a different computer with access to Dropbox. It's really easy to clone and pull files from the remote and code anywhere!

cd ~/Sites
git clone -o Dropbox file://$HOME/Dropbox/Repository/project.git

You should now see the new project folder on inside your ~/Sites folder as it was when you left if on your other computer!

Just rememeber to push any changes made here to the Dropbox remote and then git pull origin master will pick things up again on any other computers that have cloned the repository. Cool eh? Saves room in my pockets where a USB drive used to be :)

Most recent posts

  1. Getting around Apple's silly rules for iOS 10
  2. Localising App Names for iOS and Android
  3. Today - Powerful To-Do App Now Available on iOS & Android
  4. New app 'Gem Plinko' Released on iOS
  5. Spooktacular Creeps For iOS & Android

Search site:

Apps by Ubacoda.com

Click the app icons to see more info


Archives

Categories