Unable to change Visual Code repository settings - windows

I searched a lot for solutions for it, tried many ways to reset everything to 0.
I tried to set up visual studio (Windows 10 64 bits) to work with bitbucket without success.
It never accepts my password, even when I reset it.
Tried to delete any folders that would have settings without success either.
Tried to revert it to GitHub with no success either. Deleting the repositories did not improve.
Looking for git in: C:\Program Files\Git\cmd\git.exe
Using git 2.18.0.windows.1 from C:\Program Files\Git\cmd\git.exe
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: d:\
> git fetch
> git status -z -u
> git check-ignore -z --stdin
Missing or invalid credentials.
Skip fetch commands
Missing or invalid credentials.
Skip fetch commands
remote: Unauthorized
fatal: Authentication failed for 'https://bitbucket.org/gusnd/mem/src/master/'
> git symbolic-ref --short HEAD
> git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose
After unistalling git things worked fine but, if I reinstall it, I get the same issue.
Any ideas?

ok, I found a hidden .git folder on D: drive root... and other files on program data, seems to be fixed

Related

How to deal: not a git repository: '/home/user/git' even if it is

Some time ago i created a 'git' directory in a home path, just to store repos i use. But this somehow broke all my git system and even in ~ folder, when i was trying to use git, i was outputting me this (PWD=/home/user):
$ git status
fatal: This operation must be run in a work tree
I've removed 'git' folder, but appear another problem (PWD=/home/user):
$ git status
fatal: not a git repository: '/home/user/git'
I tried to reinstall git. Not helped. I'm a bit confused about this.
UPD #1:
I'm sorry for bad explanation at the beginning.
This should be clear enough:
$pwd
/home/user/MyGitRepos/some_repo/
$ls -a
. .. .git README.md
$git status
fatal: not a git repository: '/home/user/git'
Any path i am /, /etc, /home/user/ gives me the same output:
fatal: not a git repository: '/home/user/git'
Double-check your environment variables.
If you have GIT_DIR or GIT_WORK_TREE set to /home/user/git, that would explain the error message.
Check also git config -l --show-scope --show-origin in case any configuration would also reference that path.

Making a bullet-proof Git checkout in our CD job

The simplified story is that we have a site installed on multiple servers (e.g QA, Prod).
Git is set to another branch/tag for every environment, and we have deployment scripts that are generic for all environments to make things simple. The scripts are getting the desired branch/tag and then run the following commands:
GIT_CHECKOUT="${1:-develop}"
git clean --force --quiet
git fetch --all
git pull --all
git checkout $GIT_CHECKOUT
We have a few issues with that:
Since we want to support both branch and tags we use both git pull and git fetch and git pull fails on the detached head mode, that works but it throws irrelevant errors to our logs
Sometimes checkout fails because of a dirty environment (usually it happens without us knowing what caused it in the first place since no one changed files manually on those environments)
I took a look on the way Jenkins do it and it looks something like that:
> git fetch --tags --progress https://myrepo.com/repo.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse origin/mytag^{commit}
> git rev-parse mytag^{commit}
> git config core.sparsecheckout
> git checkout -f hash-of-commit
> git rev-list --no-walk hash-of-commit
Finally, the questions:
Should we work only in detached head mode when deploying? It does sound like a more stable solution.
Is there a "recipe" for that task? It is a very common task, and despite that, I couldn't find any online recipe to do it with your own bash script
It makes sense that on 'detached HEAD' you get an error when trying pull... because pull uses the upstream branch to merge... if you are on detached HEAD, you won't have an upstream branch. Doing git fetch should be enough to update the remote information on the local. If you really want to do checkout and don't want to care for if you have a dirty environment or not, you might try gir reset --hard instead.
This is what I would do:
git clean --force --quiet
git fetch --all
git checkout --detach # disconnect from whatever branch I was working on
git reset --hard $GIT_CHECKOUT
The only thing is that you are not moving anything locally (no local branches are moving with the remote branches, for example).
My take would be this (untested):
GIT_CHECKOUT="${1:-develop}"
# cleanup *every* untracked file and dir
git clean --force -d -x --quiet
# undo every change to untracked files - might disturb update
git reset --hard HEAD
# now the working tree should be *pristine*
# update all tracking branches and tags
git fetch --all --tags
git checkout --detach
# delete any local branch
git for-each-ref --format="%(refname:strip=2)" refs/heads |xargs -r git branch -D
# checkout
git checkout $GIT_CHECKOUT

git checkout -- <filename> doesn't recover a locally deleted symbolic link on Windows 10

So, yes, I am using Windows 10, when everyone around me at the office is using Linux/Mac. But I won't give up.
I deleted a Symlink which is part of the repo, that was locally created by "git clone" - (Read below why if you are bored)
Now when I run "git status" it says : "Deleted" for my symlinks. I want them back, so I tried the following :
git checkout .
git checkout --
git reset --hard HEAD
Nothing worked, they all completed without errors, but "git status" still shows the symlinks are deleted, and indeed "ls" shows they are gone. Any attempt to create them myself using "ln -s" (in git-bash) results in "typechange" in git status.
How can I get "git checkout ." or any other git command to restore the symlinks to be as they are in the repository?
So, yes, the timestamp should reveal I posted the question when I already knew the answer, but, as I spent almost two hours trying to resolve this, and the answer is not on stackoverflow (yet) I decided I shell post my question anyway and answer it.
Eitam#DESKTOP-JJOOD64 MINGW64 /d/git/my-repo (master)
$ git checkout .
Eitam#DESKTOP-JJOOD64 MINGW64 /d/git/my-repo (master)
The command seems to have completed with no errors or problems, but "git status" will still show my symlinks are not there.
The solution :
run git-bash as Administrator!!! and use "git checkout ." or "git reset --hard HEAD" or any git command that was supposed to work in the first place.
It's quite annoying that git-bash didn't complain that it's missing Administrator privileges. I found out that it's needed when I tried to work around the problem by creating the symlinks myself using "mklink" which told me I need admin priv...

git svn clone failed with couldn't truncate file at

Tried to clone my SVN repository with:
git svn clone URL -T trunk -b branches -t tags
and got this weird error:
couldn't truncate file at /usr/lib/perl5/site_perl/Git.pm line 1322.
How can I solve this?
Thx!
Tried it again with gitbash instead of windows terminal -> all OK!

how to convert svn repository to git on Windows

We have remote svn repository and we want it to convert to git.
Could you please tell me how is it possible to do it on Windows?
Thank.
Install application on Windows:
Git for Windows.
TortoiseGit
Find out the svn repository URL and copy it
Something like this:
Invoke TortoiseGit Clone dialog
Right click on destination folder, e.g. D:\SVN\ToGit, and Click Git Clone...
Check the From SVN repository checkbox
If you copied the URL first, then invoke the clone dialog, TortoiseGit will get the copied URL from clipboard and paste it into the URL text field for you. So, you don't paste it by yourself. Just have look at it to see if it's correct.
And if you right click on destination folder, TortoiseGit also fill the Directory text field for you. Also, take a look to see if it's what you want.
So, just check the From SVN repository checkbox.
And if the svn repository has the standard layout, say trunk, tags, branches, you don't need to do anything further.
Click the OK button to go
Then, starting to clone a svn repository to git repository.
Something like this:
As you can see, TortoiseGit just properly uses Git for Windows command git svn clone to clone it.
git.exe svn clone "svn://svn.code.sf.net/p/tortoisesvn/code/" "D:\SVN\ToGit\tsvn" -T trunk -b branches -t
So, basically, you can go Git Bash/CMD and re-use that command line, and also get the same result.
NOTE: If you can see the r1, r2, r3..., you can stop the cloning anytime, and resume it later by using the same command line.
Clone a local svn repository
With TortoiseGit 2.4.4+
Just copy the svn local path into URL of Clone dialog. See:
Again, Check the From SVN repository checkbox
Cloning:
TortoiseGit 2.4.4+ will use file:/// protocol to clone a local svn repository.
After you get a git repository, you can commit there. And push the commit back to origin svn repository by using TortoiseGit ->SVN DCommit..., something like svn commit.
As you can see, the command is git svn dcommit.
And if the origin svn repository has some new commit(s) need to update, you can use TortoiseGit ->SVN Rebase to fetch the svn commit and then merge/rebase on the latest commit. Something like svn update.
It uses git svn fetch then uses git rebase to merge/rebase the fetched changes.
For command line, you could just use git svn rebase.
Read Pro Git v2 - Chapter 9 for more information and examples.
You can use git-svn which is a tool that lets you convert svn repositories to git repositories. See the git documentation for more information.
Context:
Remote svn server with HUGE repository of several projects. However I only wanted to migrate one project from SVN to Git
Here's how I did it:
Requirements:
Git Extensions - Git Extensions
Visual SVN Server (also get eval license) - Visual SVN Server
Chocolatey windows package manager - Chocolatey
Git version 2.6.2 (use chocolatey in cmd: choco install git --version 2.6.2 )
What to do:
1. Get users who committed into authors file
Open cmd to root of local svn project copy and run:
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
Put the resulting authors file somewhere you can find it
Open and Edit the authors-transform.txt file by adding the name and the email into the <> line by line for each committer
2. Copy your SVN repository from the server to a local on your working drive (example: c:/repo/Repository
3. Install Visual SVN and point the storage of the server to the /repo folder
Also find an open port for it to run on
Set permissions on the authentication to windows for the server
You may have to create a user for the server as well
Also set permissions for the specific project within the server to your user
4. In the destination folder for your new cloned SVN repo hold shift and click Git Browse to open Git Extensions, go to Start, and click Clone SVN
Point to the local svn server you created for the destination (example http://localhost/svn/repo/Repository/Development/ProjectName)
I unchecked the trunk, tags, and branches but YMMV
Point the authors file to wherever it is saved
Click clone
Reasons:
Git 2.6.2 because it was the latest version that didn't cause an address issue
Git Extensions because it minimized all the command line work for the cloning
Visual SVN because I was having permissions issues on the server and the "git svn" commands responded better to an http://localhost..... address than the file:// that was suggested in the many places I researched
Chocolatey because I didn't see any other way to get that version of Git
I ended up doing this so much, I made a batch script to help out:
usage: SvnToGit <path/to/svn-repo> <local-checkout-dir> <remote-git-url>
Prerequisites
You should already have the URL to the empty git remote repository.
You should have a pre-existing authors.txt file at the root ready to
go.
Unless Git understands your svn format, you will need to run
svnserve to 'serve' the repo. You can create a window service to do,
something like this:
c:>sc create svnserve binpath="\"svnserve.exe\" --service -r C:\Users\UserName\Repositories\Svn" displayname="Subversion Server" depend=Tcpip start=auto
Caveats:
Check the intermediate results, occasionally something may fail
(especially svn clone).
Note the section for manual changes if needed
for tags. Perhaps, this could be done in batch file, but it seemed
complex and not a high priority for me. There is a PAUSE here, so
you can make these changes manually.
I have not tested this on many systems, you might need to tweak
the script a bit to adjust to your system.
The actual batch file:
REM Argument 1: Path to your repository
REM Argument 2: Path to your new Git working directory
REM Create authors.txt file
REM It will contain lines like:
REM SomeCoder = Some Guy <some.guy#example.com>
REM If Git is now aware of the format of svn repository, you will need to use svnserve:
REM svnserve -d -R --root path/to/your/repository
PAUSE
IF EXIST bare.git\NUL RD /S /Q bare.git
IF EXIST GitTemp\NUL RD /S /Q GitTemp
REM The following will not work, if SVN is using a newer FS than what Git is aware of
REM git svn clone file:///%1 --prefix=svn/ --no-metadata -A authors.txt --stdlayout GitTemp
REM So, use
git svn clone svn://localhost/%1 --prefix=svn/ --no-metadata -A authors.txt --stdlayout GitTemp
PAUSE
REM GitIgnore
cd GitTemp
git svn show-ignore > .gitignore
git add .gitignore
git commit -m "Convert svn:ignore properties to .gitignore."
cd ..
REM Bare Repo
git init --bare bare.git
cd bare.git
git symbolic-ref HEAD refs/heads/trunk
cd ..
cd GitTemp
git remote add bare ../bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare master
cd ..
REM clean up SVN type stuff
cd bare.git
REM git branch -m trunk master
git branch -m svn/trunk master
git symbolic-ref HEAD refs/heads/master
cd ..
REM Manual changes if needed for tags
REM git for-each-ref --format='%(refname)' refs/heads/tags |
REM cut -d / -f 4 |
REM while read ref
REM do
REM git tag "$ref" "refs/heads/tags/$ref";
REM git branch -D "tags/$ref";
REM done
PAUSE
REM Working Directory
git clone bare.git %2
cd %2
git checkout master
git remote remove origin
PAUSE
git remote add origin %3
REM Then
git push -u origin master

Resources