I am using XCODE, and have recently decided to try using git (I am a lone app developer, so never really needed to use it). Because it used to take up a lot of storage space when I tried it previously, all of my current projects with git are stored on an external hard drive. I was wondering, however, whether it is possible to keep a development branch of a project on the hard drive of the mac, while keeping the main branch on the external hard drive. That way, I can merge the stable branches every few days to the external hard drive, and keep the development copy on my macbook to remove the need to carry my external hard drive with me everywhere I go. Is this possible? Any suggestions for a newbie on git?
To change this current working directory, you can use the "cd" command (where "cd" stands for "change directory"). For example, to move one directory upwards (into the current folder's parent folder), you can just call: $ cd ..
No problem! All you need is a shared network drive (like a dev server) that all of your developers can access. You'll set up a repository for each developer, a central bare repository for them to push files to, and a git hook to auto-deploy files to a folder of your choice.
If the complete history of your project really is taking so much space (but reconsider and check twice if it really does), here could be a way to make this work:
First have your complete history in your remote
repo (external hard drive) in a branch main
(I would keep the default branch name master
, if I were you). Making it a bare repo is a good idea, to ease pushing later on. If you haven't done it already:
$ cd /mnt/your/external/drive
$ git clone --bare /repo/where/you/currently/have/the/whole/history
Then when you want to start a new development phase, take a shallow clone from remote
to local
(your laptop's hard drive)
$ cd $HOME/
$ git clone --depth 10 /mnt/you/external/drive/repo.git
This clones the repository, but only the last 10 commits are in history. That way if your history really is enormous, you'd save space (again, look twice if space taken by history really is a problem).
Create a work branch as you normally would, work in that branch, merge to main
, push to remote
:
$ git checkout -b super_feature # use good branch names, not "dev"
... work, commit, work, commit, work, commit, ... time to merge.
$ git checkout main
$ git merge super_feature # I usually add --no-ff
$ git push origin main
And there you go. You worked on your local shallow clone of your remote
, with limited history.
After a while, your shallow clone will have more and more history. If history space becomes an issue again (but... you know), just ditch the shallow clone and make a new fresh one from the remote
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With