gitless-vcs / gitless

A simple version control system built on top of Git
https://gitless.com
MIT License
1.92k stars 107 forks source link

ignored files being tracked, associated with branches. #40

Closed ivirshup closed 7 years ago

ivirshup commented 9 years ago

Files and directories in a .gitignore are associated with branches. That is, if I modify files in an ignored directory in branch1, then switch to branch2, my changes will not be reflected in branch2. This can also cause problems when switching back to plain old git, as ignored files persist. So if I, following the previous gl commands, switched to branch1 with $ git checkout branch1 the modifications in the ignored directory will be lost.

The following code should replicate the bug.

$ mkdir example
$ cd example
$ gl init
# Local repo created in '/Users/isaac/Documents/tmp/example'
$ echo "leave me alone" > ignored.txt
$ echo "ignored.txt" > .gitignore
$ gl track .gitigore
# File .gitignore is now a tracked file
$ gl commit -m "Added .gitignore"
# Commit succeeded
$ gl branch -c new
# Created new branch "new"
$ ls
ignored.txt
$ gl switch new
# Switched to branch new
$ ls
$
edwardloveall commented 7 years ago

This isn't a fix, but you can use the -mo or --move-over flags to explicitly move these uncommitted changes over. From the command line help:

gl switch --help
usage: gl switch [-h] [-mo] branch

Switch branches

positional arguments:
  branch            switch to branch

optional arguments:
  -h, --help        show this help message and exit
  -mo, --move-over  move uncomitted changes made in the current branch to the
                    destination branch

Is there some way to set command defaults?

colemanbroad commented 7 years ago

Can we get confirmation from someone that this is a bug? Or, if not, some rationale why this is desirable behavior, and a workaround that allows us to replicate Git's .gitignore behavior?

spderosso commented 7 years ago

This is expected behavior, in Gitless branches are completely independent to each other and it is as if each has their own working directory. If you want uncommitted changes to follow you to the branch you are switching to use the -mo flag like @edwardloveall suggested.

The rationale for this behavior is that having completely independent branches lets you shuffle between tasks without difficulty and that keeping the changes separate is what you want in most cases.

colemanbroad commented 7 years ago

Ok good to know. Some of my git repos are organized such that large data/ repositories are within the same root folder as .git/, but hidden via .gitignore. Can i work with gitless in a way that allows me to share these resources between branches without having multiple copies?

On Tuesday, October 11, 2016, Santiago P De Rosso notifications@github.com wrote:

This is expected behavior, in Gitless branches are completely independent to each other and it is as if each has their own working directory. If you want uncommitted changes to follow you to the branch you are switching to use the -mo flag like @edwardloveall https://github.com/edwardloveall suggested.

The rationale for this behavior is that having completely independent branches lets you shuffle between tasks without difficulty and that keeping the changes separate is what you want in most cases.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sdg-mit/gitless/issues/40#issuecomment-252940120, or mute the thread https://github.com/notifications/unsubscribe-auth/ACT_WJpNxCy-6oSfXtxrXaxSbgrd1lUSks5qy6IUgaJpZM4FXxOw .