Unset core.editor in Msysgit - text-editor

I set my editor per an SO entry: How do I setup DiffMerge with msysgit / gitk?.
I'm wondering how to undo this because I want to switch back to the default editing program.

Depending on how you ran git config...
git config --unset core.editor
Or
git config --global --unset core.editor

Related

skip pre-push husky for git tag?

I have a pre-push file
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm run build && git add dist && git commit --amend --no-edit --no-verify
the problem is this will run git push origin tag myTag, how to avoid this? I know I add --no-verify but it's annoying.
It's not the pre-push file that is pushing the tags - it is your git push command. --no-verify doesn't do anything here, it only affects the pre-commit hook. I think you only believe --no-verify does something because you ran git push twice; on the second time, there were no tags to push that origin didn't already have.
To actually fix this, use the --[no-]follow-tags flag
git push --no-follow-tags
To make this setting permanent for your project, configure push.default to prevent the pushing of tags by default:
git config push.followTags false

Is there a way for Jenkins or Crontab to push commits automatically to a GitHub repo?

I've been trying to push commits created with a simple shell script:
cd $dir
git add . && git commit -m "Test commit" &&
git push --all origin
The script does the job perfectly. Yet Crontab is stuck at making commits locally and Jenkins is getting 'Permission denied' when accessing a local git folder even if I assign Jenkins a group that owns the folder.
I tried Jenkins jobs with Execute shell either with the code or the path to the script. Any help would much appreciated.
One thing to note is that Jenkins goes back to the original workspace to run each command. So when you run cd $dir, the script will switch to $dir, but once you start the git add... command, it will go back to your workspace directory. To prevent this, either chain the commands together:
cd $dir && git add . && git commit -m "Test commit" && git push --all origin
or use dir to wrap the git commands so that they always run in that specific directory.
As advised by #M B summarizing:
Crontab:
For the cron commits to be pushed automatically:
Add a hook file to your git directory:
How can I automatically push after committing in Git?
Jenkins:
To commit and push automatically add a node. I also added to a sudoers file by sudo visudo:
jenkins ALL=(ALL) NOPASSWD: ALL
%sudo ALL=(ALL:ALL) ALL
I have also assigned a safe directory:
git config --global --add safe.directory /path/to/your/git/dir
EDIT: Just tested with Amazon EC2 Plugin, after cloning the repo on an EC2 instance use:
git remote remove origin
git remote add origin https://ghp_TOKEN#github.com/USER/REPO.git
git add . && git commit -m "COMMIT" && git push --all origin
And these 3 also work for Crontab and Terraform (no other settings needed).
Hope this helps.

This Git command (git commit -m 'initial') cannot execut [duplicate]

This question already has answers here:
Git: Please tell me who you are
(3 answers)
Closed 2 years ago.
when I run the git commit -m 'initial' command it shows me the below error
Author identity unknown
Please tell me who you are.
Run
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
to set your account's default identity. Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address
The Git tells you to set your identity before doing git operations. So, complete that by entering the git commands.
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
THese commands are used to set your identity to your git terminal after setting this up. you can able to do the git operations you want

bower behind a proxy

bower install behind a proxy fails in timeout with the following settings (some set are useless...) :
git config --global http.proxy fr-proxy.example.com:3128
git config --global https.proxy fr-proxy.example.com:3128
export http_proxy=http://fr-proxy.example.com:3128
export https_proxy=http://fr-proxy.example.com:3128
npm config set proxy http://fr-proxy.example.com:3128
npm config set https-proxy http://fr-proxy.example.com:3128
npm config set registry http://registry.npmjs.org/
I have also tried an install/uninstall of bower and a bower clean cache.
Edit your .bowerrc file and add the wanted proxy configuration:
{
"proxy":"http://<host>:<port>",
"https-proxy":"http://<host>:<port>"
}
If working behind an authenticated proxy, user and password should be included like this:
{
"proxy":"http://<user>:<password>#<host>:<port>",
"https-proxy":"http://<user>:<password>#<host>:<port>"
}
Usually, the .bowerrc is next to the bower.json. And if there is no .bowerrc file near the bower.json file, you can create one by yourself.
I have problem with bower list command, which was caused by the fact that bower use git with git:// URLs to get the list of remote GitHub repositories, but git:// protocol is blocked by our corporate firewall. In order to solve this problem in addition to setting environment variables, I have to add extra configurations to git too. Here's full list of commands I have to execute (remember to replace proxy host and port with yours):
# set proxy for command line tools
export HTTP_PROXY=http://localhost:3128
export HTTPS_PROXY=http://localhost:3128
export http_proxy=http://localhost:3128
export https_proxy=http://localhost:3128
# add configuration to git command line tool
git config --global http.proxy http://localhost:3128
git config --global https.proxy http://localhost:3128
git config --global url."http://".insteadOf git://
Standard environment variables in Bash are uppercased, for proxy those are HTTP_PROXY and HTTPS_PROXY, but some tools expect them to be in lowercase, bower is one of those tools. This is why I prefer to have proxy set in 2 cases: lower and upper.
Bower is using git to get packages from GitHub, this is why configuration keys need to be added to git too. http.proxy and https.proxy are proxy settings and should point to your proxy. Last but not least you need to tell git not to use git:// protocol, because it may be blocked by firewall. You need to replace it with standard http:// protocol. Someones suggest to use https:// instead of git:// like following: git config --global url."https://".insteadOf git://, but I was getting Connection reset by peer error, so I'm using http://, which is working fine for me.
At home I don't use any proxy and don't have corporate firewall, so I prefer to switch back to "normal" no-proxy settings. Here's how I do it:
# remove proxy environment variables
unset HTTP_PROXY
unset HTTPS_PROXY
unset http_proxy
unset https_proxy
# remove git configurations
git config --global --unset http.proxy
git config --global --unset https.proxy
git config --global --unset url."http://".insteadOf
I'm not very good at remembering things, so I would never remember all those commands. On top of this I'm lazy and would not want to type those long commands by hand. This is why I was creating functions to set and unset proxy settings. Here's 2 functions I've added to my .bashrc file after some aliases definitions:
set_proxy() {
export HTTP_PROXY=http://localhost:3128
export HTTPS_PROXY=http://localhost:3128
# some tools uses lowercase env variables
export http_proxy=http://localhost:3128
export https_proxy=http://localhost:3128
# config git
git config --global http.proxy http://localhost:3128
git config --global https.proxy http://localhost:3128
git config --global url."http://".insteadOf git://
}
unset_proxy() {
unset HTTP_PROXY
unset HTTPS_PROXY
unset http_proxy
unset https_proxy
git config --global --unset http.proxy
git config --global --unset https.proxy
git config --global --unset url."http://".insteadOf
}
Now when I need to set proxy, I just execute set_proxy command, and to unset unset_proxy command. With the help of Bash's autocomplete I don't even need to type those commands, but let tab complete them for me.
My script (using git bash on Windows) for setting proxy was executed by a different user from the one I was using for bower. The environment variables were not taken into account.
So the following setting is sufficient, as specified in other answers:
export http_proxy=http://fr-proxy.example.com:3128
export https_proxy=http://fr-proxy.example.com:3128
If your OS is Linux or OS X try the following command
bash
http_proxy='proxy server' https_proxy='proxy server' bower

Gitlab setup, rake fails because no --global user.name

Following the 5.1 instructions to install gitlab
https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md
When I run the command to test the install, I get an error "Git configured for user? ... no"
root#gitlab:/home/git/gitlab# sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Checking Environment ...
Git configured for git user? ... no
Try fixing it:
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab#gitlab.ac"
For more information see:
doc/install/installation.md in section "GitLab"
Please fix the error above and rerun the checks.
Has python2? ... yes
python2 is supported version? ... yes
At no point in the instructions does it say to setup a user.name and user.email for the git user.
Can I safely ignore this warning, or should I deviate from the instructions and set it?
You are right it doesn't. This configuration is needed when you edit something from the web interface. I sent a pull request to include it in installation docs.

Resources