Why does my git bash always start at master branch? - bash

I have a Windows PC with git installed. Whenever I start git bash, it always stand at /c/Users/_user with master branch as below:
NativeKiwi#nkiwi MINGW64 ~ (master)
I think it should look like this:
NativeKiwi#nkiwi MINGW64 ~
I had a look at people around, found out that they don't have (master) at their first start using git bash. I checked git repo at where I stand with git remote -v but there is nothing.

The string shown in your prompt depends on your PS1 environment variable.
Please check your .bash_profile or .bashrc for the configuration of PS1 environment variable.

I had the same issue (due to running git init) in the wrong directory and fixed it by running rm -rf .git in that directory.

You are seeing master because you created a git repository at the current path using the git init command. Always create git repositories in the folders containing project files. Consider running rm -rf .git command.

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.

Git clone on windows : git#github.com is not a git command

I'm trying to clone a repository the ssh way from github and another form gitlab
I'm on windows EDIT : with Git v 2.29.2.2
I'm getting the following error, which I do not understand from what it is coming from :
$ git clone git#github.com:math-gallou/AI21_TPs.git
Cloning into 'AI21_TPs'...
git: 'git#github.com' is not a git command. See 'git --help'.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
So I also tried :
$ git clone "ssh://git#github.com:math-gallou/AI21_TPs.git"
and
$ git clone ssh://git#github.com:math-gallou/AI21_TPs.git
But the same exact error comes out.
When I do the ssh -v git#github.com I can connect with success.
So what did I miss ?
First, if you are trying the ssh:// syntax, then the URL would be:
git clone ssh://git#github.com/math-gallou/AI21_TPs.git
^^^ /, not :
Second, check if you have a %USERPROFILE%\.ssh\config file with a github.com Host entry in it, whose content might be incorrect or mis-interpreted.
In my case, I defined system environment variable GIT_SSH to use openssh I installed, and then git is broken and I got git: 'git#github.com' is not a git command. See 'git --help'..
After deleting system environment variable GIT_SSH everything works again.
Then I tried to define user environment variable GIT_SSH and restart system (I didn't restart system in previous try), somehow now my git works correctly with openssh I installed. I don't know which part is wrong in my previous try but I decide not to waste more time on this.

How to clear the (Master) sign from git bash?

I have a Windows PC with git installed. Whenever I start git bash, it always stands at /c/Users/_user with the master branch as below: user#DESKTOP-VE8378L MINGW64 ~ (master)
I guess it should look like user#DESKTOP-VE8378L MINGW64 ~
I had a look at people around, found out that they don't have (master) at their first start using git bash. I checked git repo at where I stand with git remote -v but there is nothing.
I tried git status but there is also nothing to help.
maybe you created a git repository in your home directory?
Do you have a .git directory in your home?
If that's the case you should move that repository in a different directory, or delete the .git direcotory if it was created by mistake.

Can't commit update-index on Windows

I have a executable file called post_deploy that's run on my OpenShift gear after a push, but it wasn't executable so I ran:
git update-index --chmod=+x .openshift/action_hooks/post_deploy
But every time I did a git add to commit the file, the file would loose the executable permission. If I tried to do a commit, git would tell me there was nothing to commit. I eventually had to pop over to Cygwin to get it to work, but how can I get this to work in Window's Command Prompt?
Check your Git version: with Git 2.9.1, you can add with chmod
git add --chmod=+x -- yourFile
Also check the value of git config core.filemode. I suspect it should be false (which is expected in an environment which does not support executable bit).
Still, the add --chmod=+x should be enough to record that executable bit in the Git repo.
Finally, clone your repo in a Linux/Cygwin environment and check if the file is not already executable there.
The OP NicholasJohn16 reports below using "How do I remove files saying “old mode 100755 new mode 100644” from unstaged changes in Git?" to solve the issue.

Setup a git bare repo on a windows apache server

I need help in setting up a bare git repo on an apache web server. I followed the below instructions
$ cd /var/www/htdocs/
$ git clone --bare /path/to/git_project gitproject.git
$ cd gitproject.git
$ mv hooks/post-update.sample hooks/post-update
$ chmod a+x hooks/post-update
I got these instructions from here
http://git-scm.com/book/en/Git-on-the-Server-The-Protocols.
I try to run
git clone "http://ip-addr/gitproject.git"
, but am not successful and neither the push command works. Do you have any suggestions on what to do next.
At least try it without the double-quotes:
git clone http://ip-addr/gitproject.git
And if it still hangs, check the log of your Apache server, to see if it is contacted at all.

Resources