Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The most common case is if the master branch is updated after you've already split a new branch off of it. You won't be able to merge in your branch if it's missing commits that are in master, so you'll need to merge master into your branch. To do this, you'll need to be in your branch. Run "git pull" to grab all the latest changes, then run

git merge <branch-name> 

or git merge master  in this case to make the merge. If you're lucky, this will be all you need to do, but sometimes you'll run into dreaded merge conflicts

...

These are the ones that are probably most useful to developers starting out. A more in-depth cheatsheet can be found here or here or here.

CommandDescription
git clone <link> 

Creates a copy of a repository from a specified link and downloads it to the local machine.

git pull 

Fetches changes from a remote repository and merges them into the current branch.

git add
<paths
<path(s)-to-
files
file-or-
folders>
folder> 

Stages

changes

specific files or folders in the working directory for the next commit.

git add -A 

Stages all changes, including untracked files and deletions, in the working directory for the next commit.

git add . 

Stages all changes in the current directory for the next commit.

git commit 

Records changes in the staged area, creating a new commit. Opens the default text editor for the user to specify a commit message.

git commit -m "<message>" 

Records changes in the staged area, creating a new commit with a commit message specified in the command itself.

git push 

Pushes local commits to a remote repository, updating the remote branch with the latest changes.

git status 

Displays the status of changes as untracked, modified, or staged in the working directory.

git branch 

Lists all local branches and highlights the currently active branch.

git branch -a 

Lists all branches including remote branches.

git checkout <branch-name> 

Switches between branches or restores working tree files.

git checkout -b <branch-name> 

Creates a new branch and switches to it in a single command.

git merge <branch-name> 

Merges changes from a specified branch into the current branch.

git diff 

Shows the differences between the working directory and the staging area.

git diff --cached 

Displays the differences between the staging area and the last commit.

git fetch 

Fetches changes from a remote repository without merging them into the local branches.

git log 

Displays the commit history, showing details like commit messages, authors, and timestamps.

git log --oneline 

Displays a simplified one-line commit history, showing abbreviated commit hashes and commit messages.

git stash 

Temporarily saves changes that are not ready to be committed, allowing you to switch branches or perform other tasks.

git stash list 

Shows a list of stashed changes, including stash IDs and descriptions.

git stash pop 

Applies the latest stash and removes it from the stash list.

Resources

This article only provides the minimum information required to get started on Controls with Git; Git can do quite a bit more, and becoming familiar with its capabilities will place power in your hands. Some additional resources to further your knowledge include

...