Skip to content

Charlsz/git-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Learning Git

Commands used:

Shows the installed git version

git --version

Provides help about commands

git help <commands>*

Local repository

Configure the user

git config --global user.name <user>

Configure the email

git config --global user.email <email>

Lists the git configuration

git config --list

Initializes a new repository

git init

Lists the status of the files

git status

Adds all pending changed files

git add --all

Adds all pending changed files from the current folder

git add .

Saves all added files to the local repository

git commit -m "<message>"

Opens an editor and allows you to modify the last commit (Replaces the last commit)

git commit --amend

Creates a tag

git tag <tag> -m "<message>"

Lists tags

git tag

Deletes a specific tag

git tag -d <tag>

Creates a tag on a previous commit

git tag -a <tag> <commit> -m "<message>"

Shows information about the tag

git show <tag>

Undoes the last commit, removing the changes from the staging area

git reset

Undoes the last commit, keeping changes in the staging area

git reset --soft

Switches to a specific commit losing all later changes

git reset --hard <commit>

Shows the commits made so far

git log --oneline

Lists all commits from all branches graphically based on the current branch

git log --oneline --graph --all

Switches to a specific commit with all its changes

git checkout <commit>

Shows the changes between two commits

git diff <commit> <commit>

Creates a new branch

git branch <branch>

Shows which branch we are on and lists the others

git branch

Moves from the current branch to a specific one

git checkout <branch>

Creates and switches to the new branch

git checkout -b <branch>

Renames the current branch

git branch -m <branch>

Deletes a branch

git branch -d <branch>

Merges two branches. Brings the changes from the specified branch into the current branch

git merge <branch>

Merges two branches but keeps them. Generates a merge commit on the current branch

git merge --no-ff <branch>

Brings commits from another branch to the current branch reorganizing the commits

git rebase <branch>

Remote repository

To upload our project we must create a remote repository. When created, it will show us a series of commands to upload the project. It will ask for your git account username and password if you haven't registered it yet.

Link remote repository with local repository

git remote add origin <url>

Change the remote repository URL

git remote set-url origin <url>

Shows which remote repository we are linked to

git remote -v

Uploads the local repository changes to the remote one and specifies the main branch

git push -u origin <branch>

Uploads the local repository changes to the remote one on the main branch

git push

Uploads the local repository changes to the remote one on a specific branch

git push origin <branch>

Deletes a remote branch

git push origin --delete <branch>

Uploads all local tags to the remote

git push --tags

Deletes a remote tag

git tag -d <tag>
git push origin :refs/tags/<tag>

Downloads changes from the remote repository and updates the local one on the default branch

git pull

Downloads changes from the remote repository and updates the local one on a specific branch

git pull origin <branch>

Clones a remote repository on the default branch

git clone <url>

Clones a remote repository on a specific branch

git clone --branch <branch> <url>

About

learning git

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published