DEV Community

Git commands

Temitope Ayodele on May 03, 2020

Here is a list of some useful git commands. Initialize empty Git repository git init Enter fullscreen mode Exit fu...
Collapse
 
fcojavier0099 profile image
FcoJavier0099 • Edited

Hello, when you clone a repository, then the command:

  • git push

Works as spected, becase the remote repository is configured with the master brach by default.
If isn´t the case you would configure it with:

  • git push -u origin master # after this you could use 'git push' like shortcut

In general: git push -u [name of remote] [name of branch]
at this manner when you are in any configured branch, 'git push' makes a push from the current branch to the remote.

Thanks for share

Collapse
 
peter279k profile image
peter279k

I also use following command to delete remote branch:

  • git push origin :remote_branch_name
Collapse
 
temmietope profile image
Temitope Ayodele

Hmm. This git command actually pushes your branch to a remote branch. I guess you forgot to add --delete .

Collapse
 
peter279k profile image
peter279k

No. I've added the : in front of my remote branch.

This feature is available since Git 1.5 version is released :).

Thread Thread
 
temmietope profile image
Temitope Ayodele

Yes.. TIL. Thanks!

Collapse
 
maciekgrzybek profile image
Maciek Grzybek

Best thing you can do for your git game, is using ZSH that has a built-in git plugin. Check this out :) github.com/ohmyzsh/ohmyzsh/blob/ma...

Collapse
 
raphink profile image
Raphaël Pinson • Edited

And my two favorite aliases:

  • commend = commit --amend --no-edit
  • please = push --force-with-lease

I use these all the time in feature branches

Collapse
 
temmietope profile image
Temitope Ayodele

Yh, Nice! 👍🏽