Reputation: 137
I want to setup a local directory to push new file modifications to my Bitbucket Git repository. I originally setup a directory using the instructions online at Bitbucket, but then have since moved the location of this directory to a different location. I now get errors and I have been trying to setup this local directory.
Example: I moved
'folder/another_folder/folder_I_want_to_push_updates'
to
'folder/folder_I_want_to_push_updates'
I try the following commands and get these errors:
cd folder
in
folder
I have the sub directory
'folder_I_want_to_push_updates'
and other folders. I want to push documents to Bitbucket within sub-directories in
'folder_I_want_to_push_updates'.
$ git init
Reinitialized existing Git repository in 'folder/folder_I_want_to_push_updates'
$ git clone https://[email protected]/account/repository.git
repository has same name as 'subfolder_in_folder_I_want_to_push_updates'
fatal: destination path 'subfolder_in_folder_I_want_to_push_updates' already exists and is not an empty directory.
$ git add .
(no errors)
$ git commit -m subfolder/file.m
[master 8ac5364] subfolder/file.m Committer: name Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly. Run the following command and follow the instructions in your editor to edit your configuration file:
git config --global --edit
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test
$git push origin
warning: push.default is unset; its implicit value has changed in Git 2.0 from 'matching' to 'simple'. To squelch this message and maintain the traditional behavior ........... ........... etc. fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream
I guess there is a simple solution but I am new to Git and struggling to work it out.
Is there a way I can start over and remove all links and reconfigure a local repository to Bitbucket?
Upvotes: 0
Views: 1049
Reputation: 360
You can certainly start over! Your local repository and remote repository are equal (given you have pushed all pending commits to your local repo).
Now delete the link to your remote repo:
git remote rm
Now delete your local repo (good to make a duplicate copy), this also means delete .git. Follow: How to fully delete a git repository created with init?
Now navigate to your new folder where you want to re-link your remote and follow the bitbucket instructions or simply:
git init
git add --all
git commit -m "Initial Commit"
Log into your bitbucket remote repo:
git remote add origin https://[email protected]:7999/yourproject/repo.git
git push -u origin master
This should be fine!
Upvotes: 1
Reputation: 45
You cant clone into a folder already containing a git repository. Just do the same procedure without git init and you should be fine. Make sure you add the updates after you've done your clone to avoid information loss.
Upvotes: 1