I'm deploying an app to Heroku, which means pushing to their git repo. When do git push heroku master (or the equivalent remote alias) I get this warning:
WARNING: You're about to push to master, is that what you intended? [y|n]
Which is kinda annoying but not a big deal. However, I'm now scripting deployments so I don't want to have interact with the script - how I do get my bash script to answer y automatically?
I tried doing yes | git push heroku master but that doesn't work.
Agree with #bk2204, I would check if a git hook is being used that you are unaware of.
Git hooks are not version controlled, so make sure you are searching for this at the machine where you get this error.
The git hook may live elsewhere other than the .git directory. Check if git config core.hooksPath is set and if so, it will point to the directory where your git hook is.
The hook file that you are looking for will most likely have the name pre-push. The solution in this case is to remove or rename this hook file, and git won't run it before push.
Nope, no such file
And yet, this is exactly what a .git/hooks/pre-push would do, like this one.
To rule that out, activate (with your local Git 2.25+) trace2.
That will allow you to see what is used on the client side (your PC) by Git:
git config --global trace2.normalTarget ~/log.normal
Try your push, type 'n' (to abort), and check ~/log.normal for clues.
Just another way to solve the problem of automating responses to the prompts. You can use expect to take care of interactive warnings/ prompts.
After writing the deployment script deploy.sh, you can write a expect script and spawn the deploy script in it, for response to
WARNING: You're about to push to master, is that what you intended? [y|n]
message, you can send 'y' from expect.
The following snippet can be taken as example
#!/usr/bin/expect -f
spawn bash ./deploy.sh
expect "WARNING: You're about to push to master, is that what you intended? [y|n]\r"
send -- "y\r"
Related
This error
git: 'credential-cache' is not a git command. See 'git --help'.
is showing every time I try to interact with GitHub:
In order to get out of the pain of typing my GitHub idname & password each time I fetch, pull, merge and push changes to the GitHub, I thought of using the
git config --global credential.helper cache command to store the idname & password. After using it I learned that, as I'm using Windows, I had to use manager instead of cache to do the same task. However, the above error message is showing each time I try to interact with GitHub.
I have never used a credential helper. But, I think it would require you to install a third-party tool to get it working.
refer to https://stackoverflow.com/a/5343146/7409008
check https://github.com/microsoft/Git-Credential-Manager-for-Windows
As a recommendation, I would tell you to use ssh keys cite^ instead of a third-party tool, you are more secure this way. Even more secure if you use a passphrase along with ssh-agent cite^.
Until now I have always used FileZilla for transferring my local files to my host for changing a site Im working on. I want to change that and learn how to git gud! So basically the ideal situation would be to be able to work in VSCode on a directory which is mirrored from my web host and from there be able to make changes locally and then commit and change files on my web host when I want to - this has to be possible right?
I have been able to use Git Bash to connect to my host and files using ssh. I have created both an init --bare and init since Im not sure which one to use, but I do have the .git folder created there. I can also using the Bash and the command git status see all the files waiting for to be committed (?).
As I understand I have to initialize the repository, then commit them to "track" these files and have them visible in VSCode to work with, is this right?
But when I try to git commit following error message is displayed.
Waiting for your editor to close the file... code --wait: code: command not found.
This points to that the relative pathing to vscode and/or git is not working, but it is. When I start-up the bash I can use for example code --help and git config --global -e to launch a window of VSCode. So my git config --global core.editor "code --wait" is probably working as it should.
Although AFTER I have connected to my web host using ssh, neither of these command work anymore. Why is this?
And also, am Im on the right way right now in thinking on how to make this "connection" between VSCode, git and my web host (one.com)?
Im thinking that I have to create a local repository in the folder where I today have a duplicate of my web host-files and a remote repository at the actual web host and then make some kind of connection between them two and VSCode. Im not quite sure how yet.
Thanks in advance
I think you might be a little confused with what Git is and how you should be using it for what you want to do. Let's clear some stuff up.
Simply put, Git is a version control system for tracking changes to files over time. You create or edit your files, git add them to a "staging area" and then git commit them with a commit message. If you edit the files after committing them, then git can detect changes to the files and you can add and commit them again, or discard them depending on what you want. However the most important part to understand is that these changes are local at this point. If you want to share them with anyone (or have another system pull them down), then you will need to establish a remote repository.
This is what Github/GitLab are for. Log in/create an account on either site (gitLab provides free private repos) and create a repository named appropriately. Then once you have created a remote repo, follow the instructions to add it as a "remote" to your local repo, then git push your changes up to that remote one. Now, on your server, you will git clone the remote repo and that will pull down your changes. From then on, if you push new changes to the remote repo, you can pull the changes down to the server by doing git pull. This is a very basic and barebones approach to deploying code on the server and there are more sophisticated ways of doing it but I will keep it simple in this answer.
Git is completely separate from VSCode (although VSCode has some git integration and plugins). I would not recommend changing the core.editor to VSCode. What that setting controls is the editor that is used to author commit messages. Loading up VSCode takes too long for that...I recommend that you stick with the default Vim or use nano. Or, in most cases, specify a message when committing: git commit -m "added foobar".
So, the git repo that is on your server (the one that you init'd with --bare) is junk and should be instead created by git cloneing from a remote repo. Hopefully this makes sense!
I have a gitlab server. Gitlab has its own hooks symlinked to every git repo. I wish to be able to tell the difference in between repos when that script is called. I seen this but I don't think it provides any useful information in this case.
Perhaps it may be possible to detect which repo the hook belongs to by figuring out where the script was executed from? (The original script is in ruby) Or possibly to check /home/git/git-data/repositories/<all git users>/<all repos> for the right ref? Either way I do not know how to do that.
In your hook, you can try:
git rev-parse --git-dir
That should give the full path of the bare repo in which the hook (here a post-receive one) is executed.
That is what I used in "Is there a way to get the git root directory in one command?".
I created 2 new branches using the command line, and when I use the command 'git branch' I can see all of my branches in the window, but when I used the command 'git push' I get a message that says, "nothing to commit, working directory clean' and so I'm not seeing my new branches on github.com.
Can anyone shed some light?
Thanks!
Robin
Have you tried git push origin my_new_branch?
The below command will work:
git push origin devbranch
After running the above command git push origin dev I got this error "remote: Repository not found."
I had a similar error in which i created and published a branch on one computer. But on another It wouldnt add the branch automatically (even though the git server had the new branch). I simply did a pull from shell rather than using the app's sync function. once I did the git pull then it added the new branch and was able to be selected from the gui.
I assume this is a bug
I installed GIT onto my windows 2k8 server following these directions: http://code.google.com/p/tortoisegit/wiki/HOWTO_CentralServerWindowsXP
All commands work fine except the "push" command. I get this error:
git.exe push -v "origin" master:master
git: '/path/to/repo' is not a git command. See 'git --help'.
Pushing to user#ipaddress/path/to/repo
fatal: The remote end hung up unexpectedly
Does anyone know how to fix this?
It looks like the remote origin is not set up correctly.
I recommend re-creating that remote, either by renaming it or deleting it and making a new one:
git remote rename origin origin_backup
git remote add origin ssh://user:pass#address/path/to/repo.git
Then try again, preferably with a fetch before you push.
What protocol are you using? If git://, then make sure there is a Git daemon listening for connections. If ssh://, make sure you have ssh access and write permission on the appropriate directory tree.
Another possibility is that the server and client are running different versions of Git. It could cause problems if one is running a version that expects commands in the format git cmd and the other expects git-cmd.
First check, if your plain SSH access to 5.16.217.81 is working: is
ssh 5.16.217.81
able to open a connection to the host?
If that is successful, ensure that you specify the path to your repo in a way your SSH server understands. In the HowTo, the path is specified different from the path you typed:
5.16.217.81/d/private/test/ (your path) vs.
<server>:d:/DeeDriveRepos/Repo2
Obviously, the CopSSH server wants colons to separate the drive letter from the host, so that your URL should be 5.16.217.81:d:/private/test/.
If you used Cygwin, your URL would be 5.16.217.81/cygdrive/d/private/test/
My pushes work for msysgit version 1.6.5 but not for 1.7.x