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

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.

Related

Local project workflow with Mercurial Hg and Bitbucket

Usually I create my websites (PHP, HTML, CSS) local on my mac. I've MAMP and Mercurial (Hg) installed.
When I start a new project I draw up a new project directory in "htdocs" and begin with hg init. New files were added by hg add to the project or excluded in .hgignore. All changes in this project are completed with an hg commit.
Additional to the local project I push my whole project into a private repository to Bitbucket (hg push https://bitbucket.org/MyUser/MyProjectRepository). That works perfectly.
The problem begins when a second person works at the project at the same time. He clones with hg clone https://bitbucket.org/MyUser/MyProjectRepository my private Bitbucket repository.
When I change and commit a css file local on my mac, push it afterwords to Bitbucket and the second person changes something on his local css file at the same time he gets a merge problem when he he tries to push his changes to Bitbucket.
Does anyone know what the problem is?
The second person needs to pull and merge your changes from the bitbucket repository before pushing his changes back.
Take a look at HGInit here for a great introduction to using Mercurial with a team.

Mercurial: Build script creates 2nd line when tagging the tip

I've hunted SO for other Mercurial posts relating to tags and build scripts but I didn't find the particular issue I'm seeing.
I've been using a bitbucket.org hosted Mercurial server for a few weeks. My workflow is to write code, push to the local repo then push to bitbucket. I'm the only contributor in my project and I only use one machine to code so I haven't had any tricky merges or conflicts to resolve yet. I use TortoiseHg to perform checkins and code reviews.
Today I wrote a script to automate my builds but I ran into a problem. I use c:\dev for coding and I use c:\build as the root folder for the build process.
My process is:
1) Get the latest code -- clone the repo or get latest if it is already cloned
2) Version the code
3) Build the code
4) Tag the local repo
5) Push the tag to bitbucket.org
I'm using a simple batch program:
REM variable assignment, versioning, and error checking are excluded from this snippet
ECHO Getting code from remote repository...
IF EXIST .\%localrepo% (
ECHO Pulling latest
hg pull %localrepo%
) else (
ECHO Cloning repository
hg clone %remoterepo%
)
ECHO Done retrieving code.
ECHO Building code...
"c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" %solution% /build %solutionconfig%
ECHO Building complete.
cd %localrepo%
hg tag %version%
hg push
cd ..
This script seemed to achieve all of my goals and everything was going well until I went back to TortoiseHg and noticed that the revision Graph now shows two lines -- one for my c:\dev coding and another for the tag created by the build script in c:\build.
I don't have enough reputation to embed an image, but this link will show a screenshot of the revision history reported by TortoiseHg - http://i.imgur.com/2oNAR.png
With a bit of struggle, I merged the new line (revision 38) back to the original (revision 39), but when I ran the build script again (revision 40) the new tag continued on the 2nd line. I tried to commit a change from the dev repository, but that commit was aborted due to "push creates note remote head".
I feel like I'm maybe doing something fundamentally wrong in my build script. Any advice or topics I need to read up on? I failed to find any non-MSBuild scripting solutions relating to Mercurial code servers. I am not tied to using a batch script for any reason -- it was just a simple and free solution that I expected to be sufficient.
hg clone automatically updates your working directory to the tip of the default branch, but hg pull does not. Use hg pull -u to update the the head of your current branch after a pull.

How to configure mercurial to deploy website folder only

I have a website that I want to deploy to a clients DEV and UAT environments, the site is part of a mercurial repo - it is in the Website folder at the same level as the .hg folder. I know I can push the entire repository but would rather push only the website folder so the client does not have the other files and folders.
The repo looks like this:
Project root
.hg
Database (SQL Source Control uses this)
Documentation (All specs, pdfs, art work etc.)
Lib (pre-Nuget 3rd party dlls)
packages (Nuget stuff)
Website (this is the only area I want to deploy)
.hgignore
Project.sln
Edit:
The clients servers are not connected directly to the internet, my access to them is over a vpn and then RDP. Currently to deploy any changes I need to zip the site up, put it on a shared ftp server then wait up to 3 days for the files to be copied to the servers. Rules have been configured so I can use Mercurial over this connection.
Edit 2
I have managed to create a subrepo from the Website folder by forgetting the Website folder and all it's contents, committing the change then putting the files back, creating a repo then echoing out the .hgsub file. Locally this works for me, I can clone from the Website repo without getting any of the additional folders. However I have not been able to use this version of the repo, even if I repeat the process on our repo server. When I try to clone the hosted version down to my local working copy I get 404 errors, but I can clone the hosted version on the hosting server.
I would appreciate some step-by-step instructions (a guide for dummies if you like) on how to achive my goal; which is to be able to push only the Website folder to the clients servers. The master copy of the repo is on our repo server, I have a local clone and need to be able to push out versions from my copy.
Edit 3
Turns out that the problem I was having converting a folder to a subrepo as described in http://mercurial.aragost.com/kick-start/en/subrepositories/#converting-folder-into-a-subrepository was that the convert command, in versions after 2.1.0, is broken and is still broken in 2.3.1. After I figured that out and rolled back to that version of TortoiseHg I was able to convert the folder to a subrepo, in the root of the repo I have .hgsub which says Website = Website. I was able to work with that locally, commit to the whole repo, the subrepo, clone either the full repo or the subrepo (which is what I want), however I can't get this to work from our master repo server.
I zipped the whole thing up and ftp'd it to our remote master repo server, then set it up so I could clone from it. Directly on the server this works fine (hg clone --verbose -- C:\Repositories\EM .), however when I try to clone from the server to my local development machine with (hg clone --verbose -- https://myserver.com/hg/EM/ .) it fails with "HTTP Error: 404 (Not Found)".
requesting all changes
adding changesets
adding manifests
adding file changes
added 628 changesets with 6002 changes to 4326 files
updating to branch default
resolving manifests
calling hook preupdate.eol: <function preupdate at 0x00000000035204A8>
getting .hgignore
getting .hgsub
getting .hgsubstate
HTTP Error: 404 (Not Found)
[command returned code 255 Fri Apr 20 10:51:23 2012]
I don't know what the problem is, the files are there so why the 404?
In my opinion Mercurial shouldn't be used for this purpose. This is particularly true if that website is a web application because you shouldn't have the DLLs in Mercurial.
You should look at the web deployment tool built into Visual Studio. Have a look at this page to see if it suits your purpose.
If you can't install the required services on the destination server then it can be configured to use FTP instead.
You can not push part of repo tree
If DEV and UAT environments are unversioned targets, you can use any other way for distributing Mercurial content
You can separate Website into subrepo and will be able to push this repo
As others have pointed out you can't use push for this. Just do 'rsync' from your server to theirs. You could even automated that in a hook, where you push to a local repository and it auto-deploys to their site. Something like:
[hooks]
changegroup.deploy = $HG update ; rsync Website account#theirserver:/path/to/docroot
I have a working solution to this. I created a batch file that creates an outgoing repo and starts the built in server so I can pull from it on the client machines. First it clears out the previous folder, then clones from my local working copy (there's a parameter to determine which tag it should clone from). Next it creates a map file and converts the Website folder to a new Website2 folder in order to preserve the history then gets rid of the original folder and renames the new one. Finally it spins up the built in server.
cd c:\inetpub\wwwroot
rd /S /Q _ProjectName
hg clone -- C:\inetpub\wwwroot\ProjectName#%1 C:\inetpub\wwwroot\_ProjectName
cd c:\inetpub\wwwroot\_ProjectName
echo include Website > map.txt
echo rename Website . >> map.txt
hg --config extensions.hgext.convert= convert --filemap map.txt . Website2
cd Website2
hg update
cd ..
hg remove Website/*
hg commit -m "Removed Website"
rename Website2 Website
hg serve
So it isn't pretty, but now I just need to call the batch file and pass the tag I want to build the outgoing website from (uat, dev etc.) and give it a minute to create my Website folder, with history, that I can use to pull from or push from. I don't need to call hg serve because I know the names of the client servers so I can push the changeset out by creating aliased remote repositories. But I included that step so the client machines can pull. I haven't fully explored this option, so I'm not sure whether it's got any particular advantage. It's fine for the case when it's just me working on the project, but if any other developer needs to work on this then the Uri for their local project server will obviously be different (http://SIMON-PC:8000/ won't be the case for everyone), in which case pushing into the client might be best.
But by using this approach my local working repo doesn't need to change and so I don't get any issues communicating with our central repo, the 404 errors mentioned in edit3. I keep the entire history of the repo with the convert process, so the next time I need to send changes I'm not starting at revision 1 - in other words it isn't destructive of the Website and although I am deleting the entire outgoing repo (_ProjectName) each time I am retaining the history and yet in a position to pull / push ONLY the Website directory because it is created each time as a 'standalone' repo

How to clone Mercurial to Subversion?

I'm a VERY happy user of bitbucket and mercurial after years of putting up with subversion (and CVS, SourceSafe and others; anybody remember SCCS?). I've considerable project history now in my local hg repo, pushed daily to bitbucket and thence to my home machines.
Problem is, my company wants me to maintain a copy of this history in subversion. And I've hit a stone wall trying to set this up. I've installed hgsubversion, I think correctly. And I've used svnadmin to create an empty svn repository ready to hold the hg history.
But now what? The instructions say to start by pulling a clone (of nose? what's that? I assume this means checkout a copy of the new empty svn directory. OK did that.
But now what? I assume the next step is to push my real local hg clone to the empty svn repo I just checked out. But nothing I've tried will do this. Pull fails as follows, reporting "unrelated repository" (as I recall I gate it the URL of my master local hg repo to get around the "Needs a URL" popup on everything else I've tried.
found new changeset 139d02f4b233
examining 4e97a23b6815:342df9e52cec
abort: repository is unrelated
[command returned code 255 Mon Apr 25 11:29:33 2011]
The result of all this fumbling around is a directory with .hg, .svn and .hgignore entries and nothing else.
So, I feel I'm missing something basic that hundreds of others must have tried by now. Can someone please help me get started? Thanks!
PS: Currently the intent is to maintain SVN permanently as the team repo and push changes there from Hg periodically which would remain the main client for me indefinitely. In case this matters...
You can use the convert extension:
hg convert --dest-type svn mercurialrepo svnrepo
And hgsubversion allows you keep both of them in sync ( bidirectional)
Answered here at SO already:
Converting from Mercurial to Subversion
Migrating from Mercurial to Subversion
Perhaps look at the answers to this question.
Hgsubversion is for working with a repository cloned from SVN using Hg, not the other way around.

How to initialize google-code project in Mercurial

I have started a Mercurial based project on google code.
I have worked in subversion for sometime, but I am confused with what to do what in Hg.
I would like help on the following:
How do I initialize project (first on my local machine) (then from my local copy to google's server)
How do I get my copy of a build from the server
How do I update(merge/sync) my local changes back to the server
My project is in PHP and I am using netbeans
Both barkmadley and RC touch on it, but what you're explicitly missing is that your order is wrong in step one. Create the empty repo on google, clone it to local, and then commit locally and push. Don't try to create it locally and then push to google. There's nothing inherently wrong with the idea of doing it that way, but it's not the workflow for which google is set up.
For what it's worth, I wrote a blog post about Managing a Google Code project with Mercurial
Here's some infos:
For #1: initialize the project on google-code, then clone the repository locally (hg clone ...), add you files to the directory created by the clone process and commit that (hg commit -m 'your message' then push (hg push).
For #2: see #1
For #3: to update you local copy (hg pull -u) and to commit your change hg commit followed by hg push
As mentioned by barkmadley, Hg Book is worth reading
Hg Book should help.
when you create a project you can select the version control system used.
from there you should be able to get hg clone instructions from google code on the downloads tab.
this will give you an initial checkout of the system. Then you copy your work into it, and hg push and hg pull to sync between the google repository. To save changesets to your local copy use hg commit
Try reading this user contributed wiki. It is quite straigtforward I reckon.