How to set up ssh communication with Bitbucket using Mercurial? - version-control

I am following this tutorial on establishing the ssh communication.
Everything goes fine until I get to:
Step 7. Change your repo from HTTPS to the SSH protocol
I have no idea what the first step means. I have no .hg folder and if I create one using hg init, there is no hgrc file in it.
I came to a new location and I want to clone repositories from Bitbucket using ssh to start working.
Also I have no idea what is meant by myquotefork. It does not appear in the previous text.

If you simply just want to clone an existing repository from Bitbucket using SSH instead of HTTPS, that is quite simple. From the command line on your local computer (where you want the repository cloned to), write the following command:
hg clone ssh://hg#bitbucket.org/claims/nodatime
You will now have the repository cloned to the nodatime folder. And inside the nodatime folder, you should also have a .hg folder containing a hgrc file with the content described in point 3 in your question.
I haven't read the tutorial you're following, but point 1 expects that you've already cloned an existing repository. The .hg folder is created when you initialize/clone a repository. The hgrc file inside this folder is however only created when you clone an existing repo (and not when you just initialize one), which is probably why you didn't see it.

Related

Switching Remote Urls from HTTPS to SSH

I tried to switch from a HTTPS to SSH repo using git. Below are the first commands I used.
Then, when I tried to add a branch to the staging area, I got the following messages:
I am not able to push anything or add any commits to git from my command line either. I get an error saying "could not read remote repository". Could someone please help me? What should I do now? I am new to git and I don't want to dig myself in a deeper hole!
Check for a .git/ subfolder in:
your current working directory (where you switch to SSH)
your parent folders
If you see one in any parent folder, that would make your current working directory a nested Git repository.
Ideally, there should not be any parent Git repository above your own: see if you can remove those parent .git folders (or move them elsewhere).

vagrant-Git repository

I'm using vagrant to clone my git repository. I deleted my repository from GitHub my git account. now trying to clone a repository couldn't error message is destination path already exist. how do I delete this already existing path and start afresh?
Similar to this answer, you can:
test if a folder exist (File.directory?(directory))
delete it, using FileUtils.rmdir(disks_directory) (as used in this Vagrant script)

Creating new git repository, can't add directory

I am about to throw my laptop through a wall, and am hoping for help before reaching that point. For reference, I am following these instructions exactly - https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/.
I have a directory ".../path/thisdir". Inside of thisdir are (1) a file called Demo.R and (2) a directory called sportVU. sportVU is a directory with ~15 files in it.
When I follow the instructions in that link, my github repo looks like this:
https://github.com/NicholasCanova/packageSportVU
Notice that the sportVU directory link cannot be clicked in github, and when I download the repo, sportVU is an empty folder. Why is this happening? This shouldn't be so tough.
EDIT: this is what the repo looks like in my local machine, I'm 100% sure it's not empty:
It could be that you have two .git folder in your directory. View hidden folders to see.
Similar questions:
What does a grey icon in remote GitHub mean
Why can I not open my folder in GitHub?
Since Git doesn't store empty folders the steps you should follow exactly are:
Delete the old repo and start again following exactly my steps.
git clone <repo url>
Inside the folder of the cloned repo create a directory manually and name it as you want i.e sportVU.
Drag and Drop all the files you want in the sportVU direcrory.
cd to Myrepo/sportVU and type git add *
type git commit -m "added some files"
git push -u origin master.
and you should be all set

How to integrate LazyBones with VCS?

I just learned about LazyBones and absolutely love it! The problem is that it generates a "code skeleton" for you before your app's VCS repo exists. And I see there is some integration capability with Git, but what about other VCSes?
Specifically, I'm using Mercurial. So ordinarily, I'd create the hg repo for my new app (on the server), clone it out locally, and some code to the cloned working copy, commit & push it.
So I ask: what is the proper workflow (or set of commands) to create a new app from a LazyBones template and integrate it with a new hg repo?
I suppose, slightly more elegant way may be:
Generate skeleton by LazyBones in SomeDir
Init Mercurial repo after it in SomeDir
Add needed files from working directory into (empty) repository
Create remote repo on server
Add remote repository URL into [path] section of local repo's .hgrc (maybe also auth. credential into [auth])
Push

Git creating directory in repository [Codespaces]

My Setup: I do the local commits in Eclipse IDE itself. My local repositories resides within the workspace as well.
Somehow I couldn't do remote commits using Eclipse so I just did, thus I've been using git bash to do remote commits to codespaces.com
git remote add origin git#codespaces.com:acct_name/repo_name
git push origin master
This has served me well so far.
Now I created another repository, let's say repo_foo.
For this repository, I want to place multiple directories(projects) inside it. I don't really need the codespaces Projects here.
I just want to be able to do this.
git remote add origin git#codespaces.com:acct_name/repo_foo/proj_1
(currently this gives no repository in path error)
So the repo structure should looks like this.
repo_foo
- proj_1
-src
- proj_2
-src
-lib
etc.
Any ideas for this?
Now I created another repository,let's say repo_foo. For this repository, I want to place multiple directories (projects) inside it.
I dont really need the codespaces "Projects" here. I just want to be
able to do this.
So you want to have nested git repositories in other git repositories? It’s unclear what your final goal is. Perhaps git submodules would serve your needs? Submodules are basically other repositories cloned into another git repository. So let’s say you have a main project, but you also have a repo for a great library you want to use. You can add the library as a submodule & refer it to the main project. That way if you make changes to the library, the projects that have that library as a submodule can be automagically updated. Quite powerful concept if you need that.
The problem from my perspective is you are convolving the concept of a directory & a repository into one thing. So when you do the following:
git remote add origin git#codespaces.com:acct_name/repo_foo/proj_1
You are saying, “Go into this repo. And create another repo in that repo.”
There will be no origin of git#codespaces.com:acct_name/repo_foo/proj_1 since the parent repo of git#codespaces.com:acct_name/repo_foo already exists.
What you need to do is setup a repo for each project & decide on a naming scheme. Something like:
repo_foo_proj_1
repo_foo_proj_2
etc…
And your git remote add origin command would be:
git remote add origin git#codespaces.com:acct_name/repo_foo_proj_1
git remote add origin git#codespaces.com:acct_name/repo_foo_proj_2
etc…
When you initialize git in a folder, all the sub folders are auto tracked. When working with multiple projects or folders, where each should be tracked independently. You should keep them at the same level.
--home
--Workspace
--project1
--project2
--project3
In case you initialize git accidently at workspace, when you check git status, it includes all the the files and folders underneath to be tracked. When you perform git remote add origin, config file under .git/config is added with a remote url which is used for push and pull operations. So if you initialize repo_foo and provide the remote add, you cannot perform the same actions under proj_1. It's automatically being tracked and all the push/pull operations will use the path present in repo_foo/.git/config file.