How to commit only a specific folder Mercurial [duplicate] - mercurial

This question already has answers here:
Mercurial (hg) commit only certain files
(3 answers)
Closed 9 years ago.
I am new on linux, and i really like it so far. But i have a problem with mercurial.
I have a folder that has 5 subfolder, each of them with a project. So i'm working at a project (a subfolder) and i want to commit modifications only from that folder.
So in linux what i did was:
cd /var/www/project_foder/subfolder
hg status //it brings all the modifications(also from other projects)
hg commit -m "Message"
but it commit all the project modifications.
How can i commit only from the selected folder modifications.
Thanks in advance for your answers!.
PS: sorry for my poor english

You can specify the folder name as argument. You can also make hg status and hg commit apply to the current directory (and sub dirs) only by using a single dot as argument, e.g.:
cd /var/www/project_foder/subfolder
hg status .
hg commit -m "Message" .

Related

hg convert from git - produces hg folder only?

I am using hg convert to convert a Git repo into Mercurial on a Mac running macOS Mojave.
I've looked at similar questions How to use hg convert properly and hg convert not actually converting? but they haven't provided a definitive answer.
The command I've entered is:
hg convert ./my-src-dir/ my-dest-dir
The output is as follows:
initializing destination my-dest-dir repository
scanning source...
sorting...
converting...
6918 commit comment.
6917 commit comment.
6916 commit comment.
6915 commit comment.
6914 commit comment.
6913 commit comment.
This continues until the most recent commit...
1 commit comment.
0 commit comment.
updating bookmarks
I'm new to Mercurial. I can't see any errors but the destination directory only contains a .hg folder.
The output of hg sum is:
parent: -1:000000000000 (no revision checked out)
branch: default
commit: (clean)
update: 6919 new changesets (update)
phases: 6919 draft
Am I using this command correctly? I'm expecting to see all my src files in the new folder.
The key is:
parent: -1:000000000000 (no revision checked out)
The conversion presumably did work but you haven't yet updated your working folder to any particular changeset. So it appears to be empty.
Not knowing what (if any) branches, bookmarks, etc. are in the repo I can't say exactly what you should update to. But let's say you just want the last revision in there, you could do:
$ cd my-dest-dir
$ hg up tip
to get to whatever it thinks the last one is.

Old HTML/CSS files did not update with git push on GitHub

I'm pretty new with GitHub and GitBash, I uploaded (by dragging the files) a folder that included my HTML and CSS files 11 days ago. Today I finally figured out how to push them with the terminal, since I "git push" my whole project, I now have the old html/css files (I dragged and dropped) 11 days before. I thought that those files (from 11 days ago) would be updated with the new code I added to those HTML/CSS files with $git push. Is it possible to combine them so that I can still have the old record but have new updates show? Or would I just need to delete the old (dragged and drop) files?
Create a new branch at the commit where old files are created (11 days ago). "git branch -b test "
Move the files out of the folder and commit
Apply the rest of commits using "git rebase --onto"
The commands in quotes are not total, but just examples
Before pushing, you need to add all files using this command
git add .
Now commit the changes you made
git commit -am "Updating some files(Whatever you want you can write as a comment)"
Now push with mentioning remote and branch, usually remote is origin and branch is master
git push -u origin master
There is a nice tutorial series about git on youtube. You can follow this tutorial from the coding train Git and Github For Poets by Daniel Shiffman.

How to uncommit in mercurial for my last commit(not yet pushed) [duplicate]

This question already has answers here:
Is there any way to delete local commits in Mercurial?
(10 answers)
Closed 8 years ago.
I have situation like this:
I have commited files a,b,c,d.Now i found that by mistake i commited
files a and b; so before pushing these changes, i want to do uncommit
files a and b so that i can push only c and d.Can someone tell me how
to do that by using mercurial commands.
Here uncommit means that i dunt want to use "hg out -p" and after that
looking change set and do things manually.
Assuming you haven't performed any other transactions on your repository since you committed the files, I think you could do this as a 2 stage process:
hg rollback
hg commit filec filed
hg rollback should remove the commit that you have just made, but leave the files as changed. Then hg commit filec filed should commit the files named filec & filed. Obviously you should replace these file names with the names of your actual files.
It's probably worth mentioning that you should be careful with hg rollback - it alters the history, so it is possible to lose data with it if used incorrectly.
hg rollback, and you can find more in the Chapter 9. Finding and fixing mistakes of the Mercurial: The Definitive Guide
In mercurial you can use the backout command, which creates a changeset that is the opposite of the changeset you want to backed out. Then this changeset is committed. The only thing you need to do after that is a merge.
You can backout any changeset, but it's not recommended to backout a merge changeset.
A detailed explanation of the command with an example can be found here.

What's the difference between copying a .hg folder and using clone? [duplicate]

This question already has an answer here:
Difference between cloning and copying in Mercurial
(1 answer)
Closed 9 years ago.
Say I need to create x repositories that can push and pull from a central repository. Is there a practical difference between cloning all those repositories compared to copying the .hg folder x times from the central repository to empty folders?
One difference I can think of is that a copy isn't an atomic operation:
you can't be certain the repo you are copying isn't being modified.
Edit: the hg clone man page actually mentions:
In some cases, you can clone repositories and the working directory using full hardlinks with
$ cp -al REPO REPOCLONE
This is the fastest way to clone, but it is not always safe.
The operation is not atomic (making sure REPO is not modified during the operation is up to you)
and you have to make sure your editor breaks hardlinks (Emacs and most Linux Kernel tools do so).
Also, this is not compatible with certain extensions that place their metadata under the .hg directory, such as mq.
Another minor difference - if you perform a copy both the original and new repository will have the same parent repository. With a clone the new repository's parent will be the original.
i.e. in the [paths] section of your .hg/hgrc file.
Original Repository (/repo/hg/original)
[paths]
default = /repo/hg/parent
Copied Repository
[paths]
default = /repo/hg/parent
Cloned Repository
[paths]
default = /repo/hg/original
Yes, there is one difference. Clone will attempt to create a hard link if both repository are on the same filesystem. (Unfortunately, this doesn't work on windows)

Is it possible to reopen a closed branch in Mercurial?

I understand that it is possible to close a named branch in Mercurial, so that it will not appear in the hg branches list:
hg commit --close-branch -m 'close badbranch, this approach never worked'
Is it possible to later re-open the branch if need be?
You can just hg update to the closed branch then do another hg commit and it will automatically reopen.
The closed flag is just used to filter out closed branches from hg branches and hg heads unless you use the --closed option - it doesn't prevent you from using the branches.
You can reopen a branch by using the "-f" flag when 'creating' the branch.
No, this command will create a new branch with the same name.
Just forget that it's closed. Switch to the branch, make the changes and commit. It will be automatically reopened. When you're done you can close it again.
try with following:
hg pull && hg update branch_name
Now make a small change to one of the file and then commit it
hg commit -m "minor change"
then push it
hg push -b .
Now you should be able to work normally.
Try this.
Switch to the closed branch before executing. ( hg up closed_branch )
hg st
touch a
add a
hg commit -m 'reopening the closed branch'
This will reopen the closed branch.