Skip to content

MLFedeB/git-on-the-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Using Git on the Terminal

A quick guide to use Git without leaving your terminal.

Getting started

  • Add your username:

    $ git config --global user.name "<username>"
  • Add your email:

    $ git config --global user.email "<email>"
  • Check if everything is alright:

    $ git config --list

This may seem trivial, but actually it's really important. If your credentials are not properly set, your commits will not appear as yours.

Clean settings

  • If you want to clean your username and email just type:

    $ git config --global --unset-all user.name && git config --global --unset-all user.email

Repositories

  • Create a new repository:

    $ git init

Clone

  • Clone a repository:

    $ git clone <repository>

    Clone a repository directly into the current directory (if empty):

    $ git clone <repository> .

Commits

  • Check for changes:

    $ git status
  • Stage all changes to be committed:

    $ git add -A
  • Commit your changes:

    $ git commit -m <message>

Branches

  • List all branches:

    $ git branch
  • Create a branch:

    $ git branch <branch-name>
  • Switch to another branch:

    $ git checkout <branch-name>

    Create a branch and automatically switch to it:

    $ git checkout -b <branch-name>
  • Delete a branch:

    $ git branch -d <branch-name>

Remotes

  • Add a remote:

    $ git remote add <remote-name> <repository>
  • Pull changes from remote repository:

    $ git pull <remote-name> <branch-name>

Stash

  • Stash changes:

    $ git stash

    Stash changes and with a description:

    $ git stash save <optional-message>

    Stash changes including untracked files and with a description:

    $ git stash save -u <optional-message>
  • List stash entries:

    $ git stash list
  • Apply saved changes from the latest stash entry:

    $ git stash pop

    Apply saved changes from the indicated stash entry:

    $ git stash pop 'stash@{n}'
  • Remove all stash entries:

    $ git stash clear

Rebase

  • Squash commits with (interactive) rebase:

    $ git rebase -i <branch>

    In case of conflict, solve them and then continue with the rebase:

    $ git rebase --continue
  • Abort rebase:

    $ git rebase --abort

Others

Rename case-sensitive file

  • Rename a file to the same name but with a different case:

    $ git mv FILE FILE.tmp && git mv FILE.tmp file

License

Do whatever you want with this, it’s public domain.

About

A quick guide to use Git without leaving your terminal

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors