Intentando rebase HEAD~5 and squash 5 commits together into 1
a establecer la rebase HEAD~5 and squash 5 commits together into 1
de 10 commits ficticios usando ruby
, system command
. Usando vim
como editor pnetworkingeterminado y obteniendo este error:
# ERROR # Vim warning: output does not networkingirect on terminal # Vim warning: input does not come from terminal
Intentando hacer:
# DESIRED # 1. open VIM terminal window # 2. manualy select files for squashing #!/usr/bin/env ruby # create dummy files 1.upto(10) { |i| `touch "file#{i}.txt"` } files = Dir.glob('*.txt') # initialize repo `git init` # commit each file separately files.each do |f| `git add #{f}` `git commit -m "add #{f} to repo"` end # rebasing `git rebase -i HEAD~5` # error
¿Alguna idea de cómo hacer que funcione y qué mejorar?
El problema con el código anterior es que estás tratando de ejecutar un command externo (en este caso, vim
través del command de rebase incorporado de git) desde ruby usando el operador backticks.
En su lugar, intente utilizar el command del system
para este fin.
Referencia: http://www.ruby-doc.org/core-2.0.0/Kernel.html#method-i-system
Entonces, el código corregido sería:
#!/usr/bin/env ruby # DESIRED # 1. open VIM terminal window # 2. manualy select files for squashing # create dummy files 1.upto(10) { |i| `touch "file#{i}.txt"` } files = Dir.glob('*.txt') # initialize repo system "git init" # commit each file separately files.each do |f| system "git add #{f}" system "git commit -m 'add #{f} to repo'" end # rebasing system "git rebase -i HEAD~5" # error