zsh/mercurial help on every command - terminal

Every command I make in terminal while in zsh I get the mercurial help appended.
Example:
$ ls
Applications Developer Library Pictures VirtualBox VMs
Consensus Documents Movies Projects
Desktop Downloads Music Public
haaduken at nachi in ~Mercurial Distributed SCM
basic commands:
add add the specified files on the next commit
annotate show changeset information by line for each file
clone make a copy of an existing repository
commit commit the specified files or all outstanding changes
diff diff repository (or selected files)
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
summary summarize working directory state
update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
$
I have absolutely no idea why. Any ideas how I can stop this? A lot of people are saying alias, but hg isn't in my alias list at all.

Did you add a Mercurial command to your PS1 variable? Some people do this, to display the current branch or bookmark.
What does 'echo $PS1' show?
It's possible you added an incorrect Mercurial command there, which results in printing the help message.

Related

Illegal Byte sequence in a file name while checking out git branch

I am using git in cli to change the current branch:
git checkout dev
and it produces:
fatal: cannot create directory at 'app/src/androidTest/java?com': Illegal byte sequence
As answered in this question and this one, I tried:
LC_ALL=C git checkout dev
or
LC_CTYPE=C git checkout dev
but I am getting the same error as shown above.
Running:
git status
shows that some of the files were changed by the checkout, but I am still on the master branch.
How can I remove the file causing the problems or how can I checkout the branch without getting this error?
The locale only affects how things are displayed. If the file name contains a character which isn't allowed by the file system, no amount of locale tweaking can fix that.
I can't think of a way to force a file system to let you create a file which then cannot be used, or a good reason to want to be able to do that.
Probably as a workaround, create a virtualized host with a bare-bones Linux system formatted to permit old-style 8-bit file names (Latin-1 or CP1252 if you can live with the unsavory Windows flavor of that), check out the file there, rename and commit the rename back to git. You still won't be able to check out versions of the source tree from before the rename.
I have found a few files in various github projects that are not compatible with one or another operating system. Files with a ".nul" or ".con" extension are a real pain on windows, for example. It isn't a problem exclusive to git. For example Subversion will abort nastily if it can't restore a file for local naming reasons.
In some cases the file may have been uploaded in error. If that is the case for your own projects it should be possible to use the git tools to list the archive and perform a delete of the file from the archive without actually instancing the file locally.
In other cases perhaps that particular file is not significant, and perhaps can be ignored. Perhaps a test will fail if it is missing?
One trick I have used is to stop the whole folder containing that file from being synced by manually creating the directory path, but for the last element, create an empty file instead of a folder. Of course, now the whole test suite will fail.
When the version control tries to do the checkout, it will simply fail to restore the folder, rather than giving a fatal error.
Of course, that only works if the folder is non-critical, e.g. some test files.
The alternative is to piecemeal check-out all but the problem file, but that can be a tedious sequence of checkouts. But you can use this attack to restore the rest of the folder that you omitted using the above technique. Alternatively, locally drag the files from the zip download if they are non-critical.

Backing out staged changes in Mercurial on a Mac

I just cloned an hg project that is typically maintained by Windows users (I'm an a Mac). I just did an hg add . and got a bazillion of the following messages:
adding out/blah
adding out/meh
adding out/fizz
adding out/buzz
...etc.
I do not want anything under out/* getting committed & pushed! So I added the following entry to .hgignore:
out/*
And then re-ran hg add .. Have I successfully prevented all this cruft living under out/* from being committed & pushed to the remote repo? If not, what else (specifically) do I need to do, and in what order?
First, check with
hg status
which files were actually added (you can also use hg status -a to restrict yourself to added files). Unless you removed them, the files in out still remain added. In order to get rid of them, use:
hg forget out
Then use hg status or hg status -a again to verify that they are no longer part of the planned commit.
I'll also note that out/* will also exclude any files in subdirectories that are named out, e.g. foo/out/bar.txt. To ignore only files in the directory out at the root, use the following line instead for your .hgignore:
re:^out/
The re: prefix will use regular expression matching instead and ^out/ will match all paths that start with out/.

'git add .' affecting line feeds of files outside .git folder

I've got a series of HTML pages and other files for a website hosted on heroku sitting under a folder named 'sitename' on the User level of my computer - Windows 8 64 bit (that is, the files are in 'C:\Users\Me\sitename'
I'm trying to deploy them to the site using this code:
$ git add .
$ git commit -am "make it better"
$ git push heroku master
When I execute '$ git add .', the console starts returning tons of messages naming certain files and saying 'The file will have its original line endings in your working directory. warning: LF will be replaced by CLRF'.
Reading the question here, I found that it probably wouldn't affect anything in my code. However, when I run the code, it doesn't just affect the files in my git repository (which I think is set up correctly by running '$ git init', which creates a .git folder on the same level as the sitename folder), but starts to affect files in my AppData folder, e.g. iTunes.
Is this expected behavior? Will it affect anything? And is there a way to direct 'git add' towards only the repository?
I would recommend investigating where your git folder really is for your project first. Because it seems like you have somehow added files from the Appdata folder to your project, this indicates that the git folder you have created is not seperated from the other folders on the server. For example you have your git folder in:
'C:\Users\Me' instead of 'C:\Users\Me\sitename'
To easily see what files that have been added to your git project/Hasn't been added you can execute the command:
git status
This will also show your current staged files and if you have commited something.
To add single files/folder just write:
git add example.html
Where example is the name of the file you want to add (it can be any extension).
To remove files just do the same but use git rm.

error: Sparse checkout leaves no entry on working directory

First, let me tell you that I have already checked all the similar threads and searched google to find what the problem may be, but no success. My problem is that I'm trying to use sparse checkout in git, but I get this error:
error: Sparse checkout leaves no entry on working directory
I have this 60GB repository, which I need to clone. I need only a part of it, so to save a disk space I wanted to use sparse checkout. This is what I do:
mkdir repoDir
git init repoDir
cd repoDir
git remote add origin <repo url>
git config core.sparsecheckout true
echo "some/dir/" >> .git/info/sparse-checkout
git pull --depth=1 origin master
Note I add the remote without -f flag, so nothing is fetched.
The result:
error: Sparse checkout leaves no entry on working directory
I tried several things:
Instead of initialising new repo and adding the remote manually, I did git clone --no-checkout and then set up the sparse checkout. This didn't help as my git status showed as if I deleted all the files in my repo. The git pull origin master command results in the same error.
Tried all possible combination of paths in step 6, with preceding slashes, slashes after the path, stars, spaces between path and > or >>. Btw I'm confused what is the correct format here, from the comments on SO I see mutually exclusive ways of formatting this.
Tried to make sure my .git/info/sparse-checkout is ASCII, and has proper line endings as found here. This is probably only problematic on Windows, but I just checked this anyway.
My git version: git version 1.9.3 (Apple Git-50)
OSX Yosemite 10.10.2 (14C109)
It turns out that "some/dir/" was wrong, since I didn't have the repository I didn't know it's real structure. I was able to browse it through web interface but I just discovered the folders don't correspond exactly to the real repository folder structure.
Lesson for the future: make sure you know the folder structure before creating sparse-checkout file.
The sequence of operations I wanted to follow is similar, namely the one suggested in this other post https://stackoverflow.com/a/13738951/5459638. I get the error message
error: Sparse checkout leaves no entry on working directory
when launching git pull <remote> <branch> with branch being master.
As #lawicko said, in the project webpage I can click my way to the subdirectory to be cloned and copy the URL of that page; ctrl+L ctrl+C makes doing this nice and quick. This URL has the form
https://gitlab.com/<username>/<project>/tree/master/<subdir>/<subdir>
The part that my sparse-checkout file accepts is the children of master
<subdir>/<subdir>/
with the trailing slash.
As an alternative to the same aim, there is another path in the form <project>/<subdir>/<subdir> to the right of the drop-down menu for switching branches at the top of the webpage.
In this case, I would have copied and pasted the children of <project> plus the trailing slash.
And this path is not as easy to copy and paste as the URL is.
Note that if you are using sparse-checkout on windows, you may need to add core.protectNTFS false per https://github.com/git-for-windows/git/issues/2777

Git (windows 7) won't add directories, but adds files files typed explicitly

trying to find an answer to this, have seen it hinted at, but no solution.
Not entirely new to git, but haven't used it in a few months... this is my first time using it on windows. using git bash.
I have a cake PHP site that I want to add exluding any cache files my .gitignore file contains only:
app/tmp/*
Here is the most basic thing I have tried:
git init
git add .
git commit
I get a message on commit saying there are untracked files - all files and dirs at the root directory.
git status
gives me the same message.
However, if I type
git add .htaccess
it stages the .htaccess file.
Also, if I do:
git add app/.htaccess
It will add that file too.
I have also tried
git add app/*
no luck.
Thanks in advance.
The files aren't ignored, because otherwise you would be forced to do a git add --force afile.
However, you might want to check GIT_DIR and GIT_WORK_TREE environment variable, and see if they reference another repository, which could explain the discrepancy between the index and what you think is your working tree.

Resources