2

Creando Shortcut en Git

Un shorcut o un alias en git, puede hacernos que el manejo de la herramienta sea más sencilla, ya que podemos acortar o renombar comandos de uso frecuente en git.

Acortar comandos
`$ git config --global alias.br branch
$ git branch

  • master
    $ git br
  • master
    `

Comando más sencillos y útiles
`$ git config --global alias.last ‘log -1 HEAD’
$ git log -1 HEAD
commit 5c1fcfb3723995945794b9e0e4787eebeb366bf1 (HEAD -> master, origin/master, origin/HEAD)
Author: Pablo A [email protected]
Date: Sun Jun 21 18:19:58 2020 -0500

Exercise Class 7 and 8 - Course: Introduccion al pensamiento computacional con Python

$ git last
commit 5c1fcfb3723995945794b9e0e4787eebeb366bf1 (HEAD -> master, origin/master, origin/HEAD)
Author: Pablo A [email protected]
Date: Sun Jun 21 18:19:58 2020 -0500

Exercise Class 7 and 8 - Course: Introduccion al pensamiento computacional con Python

`

`$ git status
On branch master
Your branch is ahead of ‘origin/master’ by 1 commit.
(use “git push” to publish your local commits)

Changes to be committed:
(use “git restore --staged <file>…” to unstage)
modified: README.md

$ git unstg README.md
Unstaged changes after reset:
M README.md
$ git add .
$ git reset HEAD README.md
Unstaged changes after reset:
M README.md
`

Renombar comandos
`$ git config --global alias.cm commit
$ git config --global alias.updcm ‘commit --amend’
$ git status
On branch master
Your branch is up to date with ‘origin/master’.

Changes not staged for commit:
(use “git add <file>…” to update what will be committed)
(use “git restore <file>…” to discard changes in working directory)
modified: README.md

no changes added to commit (use “git add” and/or “git commit -a”)
$ git cm -am “Commit 2”
[master d4ad733] Commit 2
1 file changed, 2 insertions(+)
$ git status
On branch master
Your branch is ahead of ‘origin/master’ by 1 commit.
(use “git push” to publish your local commits)

Changes not staged for commit:
(use “git add <file>…” to update what will be committed)
(use “git restore <file>…” to discard changes in working directory)
modified: README.md

no changes added to commit (use “git add” and/or “git commit -a”)
$ git add .
[email protected]:~/Documents/Python_code$ git updcm
[master 50cf85b] Commit 2
Date: Sat Jun 27 23:17:00 2020 -0500
1 file changed, 2 insertions(+)
$ git last
commit 50cf85bcf86eadadca77fe4f6e5f31b5c4bebc20 (HEAD -> master)
Author: Pablo A [email protected]
Date: Sat Jun 27 23:17:00 2020 -0500

Commit 2

`

Como se podrán dar cuenta esto nos puede facilitar mucho el manejo en Git.

Escribe tu comentario
+ 2