0% found this document useful (0 votes)
32 views

Hoja1 Comandos Git

This document provides a cheat sheet for common Git commands organized into the following categories: Git basics, rewriting Git history, Git branches, undoing changes, and remote repositories. It lists commands like git init to create a new local repository, git add to stage files for committing, git commit to commit staged changes to the local repository, and git push to push committed changes to a remote repository.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Hoja1 Comandos Git

This document provides a cheat sheet for common Git commands organized into the following categories: Git basics, rewriting Git history, Git branches, undoing changes, and remote repositories. It lists commands like git init to create a new local repository, git add to stage files for committing, git commit to commit staged changes to the local repository, and git push to push committed changes to a remote repository.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Git Cheat Sheet

GIT BASICS REWRITING GIT HISTORY

git init Create empty Git repo in specified directory. Run with no git commit Replace the last commit with the staged changes and last commit
<directory> arguments to initialize the current directory as a git repository. --amend combined. Use with nothing staged to edit the last commit’s message.

Clone repo located at <repo> onto local machine. Original repo can be Rebase the current branch onto <base>. <base> can be a commit ID,
git clone <repo> git rebase <base>
located on the local filesystem or on a remote machine via HTTP or SSH. branch name, a tag, or a relative reference to HEAD.

git config Define author name to be used for all commits in current repo. Devs Show a log of changes to the local repository’s HEAD.
git reflog
user.name <name> commonly use --global flag to set config options for current user. Add --relative-date flag to show date info or --all to show all refs.

git add Stage all changes in <directory> for the next commit.
<directory> Replace <directory> with a <file> to change a specific file. GIT BRANCHES

git commit -m Commit the staged snapshot, but instead of launching List all of the branches in your repo. Add a <branch> argument to
git branch
"<message>" a text editor, use <message> as the commit message. create a new branch with the name <branch>.

git checkout -b Create and check out a new branch named <branch>.
git status List which files are staged, unstaged, and untracked.
<branch> Drop the -b flag to checkout an existing branch.

Display the entire commit history using the default format.


git log git merge <branch> Merge <branch> into the current branch.
For customization see additional options.

Show unstaged changes between your index and


git diff REMOTE REPOSITORIES
working directory.

git remote add Create a new connection to a remote repo. After adding a remote,
UNDOING CHANGES <name> <url> you can use <name> as a shortcut for <url> in other commands.

git revert Create new commit that undoes all of the changes made in git fetch Fetches a specific <branch>, from the repo. Leave off <branch>
<commit> <commit>, then apply it to the current branch. <remote> <branch> to fetch all remote refs.

Remove <file> from the staging area, but leave the working directory Fetch the specified remote’s copy of current branch and
git reset <file> git pull <remote>
unchanged. This unstages a file without overwriting any changes. immediately merge it into the local copy.

Shows which files would be removed from working directory. git push Push the branch to <remote>, along with necessary commits and
git clean -n
Use the -f flag in place of the -n flag to execute the clean. <remote> <branch> objects. Creates named branch in the remote repo if it doesn’t exist.

Visit atlassian.com/git for more information, training, and tutorials

You might also like