Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A file in git associated with the repo, under revision control, but not associated with any particular branch?

Tags:

git

Say I have a file called: "todo"

It's a list of things I want to do for this project.

I want this file associated with my git repo.

I want there to be different revisions of this file,

however, I don't want it associated with particular branches. For example:

  1. On branch master.
  2. Create some basic ToDo items
  3. Branch "dev1"
  4. Add more stuff to todo list
  5. Branch "dev2" from master.
  6. Add more stuff to todo list
  7. Now, I have different revisions of the todo file lying all around.

I just want there to be one "todo" file -- is this possible? Does this make sense? Am I misusing todo somehow?

like image 992
anon Avatar asked Mar 22 '10 06:03

anon


People also ask

What is the tip of a branch?

The most recent commit on a branch is referred to as the tip of that branch.


1 Answers

Another trick is to use an independent branch, checked out in a subtree of your project, as Junio Hamano (the current Git maintainer) does with Git's todo. Cookbook:

$ cd project/
$ git branch
* master
$ git init META

You can now create your “To Do list” and other files in META/

$ cd META/
$ echo '* Item 1' > todo.org
$ git add todo.org
$ git commit -m 'Initial version of TODO file'
[master (root-commit) 64748ba] Initial version of TODO file
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 todo.org

Let's change the branch name to meta, too, and push it back to the main repository:

$ git branch -m meta
$ git push .. meta

You will have to remember to push the branch back after each commit; setting up a post-commit hook may be in order.

META/ now shows up as an untracked file in the main repository; let's ignore it locally:

$ cd ..
$ git status
# (Shows META/ as untracked)
$ echo META/ >> .git/info/exclude

You can now switch branches at will, and META/ will stay untouched—as long as the branch you are switching to does not include a conflicting path, of course.

The main repository now contains an additional, totally independent branch, which can be pushed and pulled as any other part of your project:

$ git branch
* master
  meta
$ gitk --all

Screenshot

like image 56
Damien Diederen Avatar answered Nov 15 '22 00:11

Damien Diederen