Questions tagged [git]

Git is an open-source distributed version control system (DVCS). Use this tag for questions related to Git usage and workflows. DO NOT USE the [github] tag for Git-related issues simply because a repository happens to be hosted on GitHub. Also, do not use this tag for general programming questions that happen to involve a Git repository.

Git is an open-source distributed version control system () with an emphasis on speed. was initially designed and developed by Linus Torvalds for kernel development, now it is maintained by Junio Hamano.

Every Git working directory contains a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.

The latest stable version is 2.30.1, released on 8 February, 2021.

Characteristics

  • Strong support for non-linear development
  • Distributed development
  • Compatibility with existing systems/protocols
  • Efficient handling of large projects
  • Cryptographic authentication of history
  • Toolkit-based design
  • Pluggable merge strategies
  • Garbage accumulates unless collected
  • Periodic explicit object packing
  • Data Assurance

Data structures

git - data workflow

External Links

Internal Links

Installation/Setup

Working with the code

Tagging, branching, releases, baselines

Git Clients

  • msysgit - Cross platform, included with Git
  • gitk - Cross platform history viewer, included with Git
  • RepoZ - Zero-effort repository hub to track and access local Git repositories for Windows and macOS
  • gitnub - macOS
  • gitx - macOS history viewer
  • smartgit - Cross platform, commercial, beta
  • tig - console GUI for Linux
  • qgit - GUI for Windows, Linux
  • Git Extensions - package for Windows, includes friendly GUI
  • SourceTree - A free Git & Mercurial client for Windows or macOS
  • posh-git - A Windows PowerShell environment for Git
  • TortoiseGit - A Windows Explorer extension with overlay icons representing the file statuses in explorer
  • GitKraken - A fancy, cross-platform Git client

Clients that are primarily used for GitHub but also support Git

Other Git beginner's references

There are also good guides if you would like to understand Git conceptually or if you would like to compare other revision control software such as subversion.

Free Git hosting

Video Tutorial

Codeschool Git Tutorial - Build a solid foundation in Git
Git Tutorial Playlist - Beginner's Guide for Git

Related tags

Chat

The Stack Overflow git chat is useful for coordinating work within this tag, and perhaps occasionally for getting quick help (though no guarantees can be made; attendance is spotty).

133870 questions
22674
votes
92 answers

How do I undo the most recent local commits in Git?

I accidentally committed the wrong files to Git, but didn't push the commit to the server yet. How can I undo those commits from the local repository?
Hamza Yerlikaya
  • 47,689
  • 37
  • 135
  • 231
17987
votes
39 answers

How do I delete a Git branch locally and remotely?

I want to delete a branch both locally and remotely. Failed Attempts to Delete a Remote Branch $ git branch -d remotes/origin/bugfix error: branch 'remotes/origin/bugfix' not found. $ git branch -d origin/bugfix error: branch 'origin/bugfix' not…
Matthew Rankin
  • 400,554
  • 38
  • 116
  • 156
12539
votes
38 answers

What is the difference between 'git pull' and 'git fetch'?

What are the differences between git pull and git fetch?
pupeno
  • 256,034
  • 114
  • 324
  • 541
9782
votes
37 answers

How do I undo 'git add' before commit?

I mistakenly added files to Git using the command: git add myfile.txt I have not yet run git commit. Is there a way to undo this, so these files won't be included in the commit?
paxos1977
  • 135,245
  • 26
  • 85
  • 125
9328
votes
34 answers

How do I rename a local Git branch?

I don't want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories. How can I rename a local branch which hasn't been pushed to a remote branch? In case you need to rename remote branch as…
Forrest
  • 101,971
  • 19
  • 69
  • 107
8002
votes
50 answers

How do I force "git pull" to overwrite local files?

How do I force an overwrite of local files on a git pull? The scenario is the following: A team member is modifying the templates for a website we are working on They are adding some images to the images directory (but forgets to add them under…
Jakub Troszok
  • 84,701
  • 10
  • 36
  • 49
7659
votes
27 answers

How to modify existing, unpushed commit messages?

I wrote the wrong thing in a commit message. How can I change the message? The commit has not been pushed yet.
Laurie Young
  • 129,506
  • 13
  • 44
  • 54
7624
votes
41 answers

How do I revert a Git repository to a previous commit?

How do I revert from my current state to a snapshot made on a certain commit? If I do git log, then I get the following output: $ git log commit a867b4af366350be2e7c21b8de9cc6504678a61b` Author: Me Date: Thu Nov 4 18:59:41 2010…
Crazy Serb
  • 76,496
  • 8
  • 33
  • 46
7300
votes
35 answers

How do I check out a remote Git branch?

Somebody pushed a branch called test with git push origin test to a shared repository. I can see the branch with git branch -r. Now I'm trying to check out the remote test branch. I've tried: git checkout test which does nothing git checkout…
Juri Glass
  • 76,369
  • 8
  • 31
  • 46
7266
votes
40 answers

How to remove local (untracked) files from the current Git working tree

How do you delete untracked local files from your current working tree?
readonly
  • 306,152
  • 101
  • 198
  • 201
6290
votes
29 answers

How to make Git "forget" about a file that was tracked but is now in .gitignore?

There is a file that was being tracked by git, but now the file is on the .gitignore list. However, that file keeps showing up in git status after it's edited. How do you force git to completely forget about it?
Ivan
  • 77,768
  • 15
  • 47
  • 57
5491
votes
15 answers

Move the most recent commit(s) to a new branch with Git

I'd like to move the last several commits I've committed to master to a new branch and take master back to before those commits were made. Unfortunately, my Git-fu is not strong enough yet, any help? I.e. How can I go from this master A - B - C - D…
Mark A. Nicolosi
  • 72,599
  • 10
  • 41
  • 46
5257
votes
36 answers

How do I discard unstaged changes in Git?

How do I discard changes in my working copy that are not in the index?
readonly
  • 306,152
  • 101
  • 198
  • 201
5011
votes
38 answers

How to resolve merge conflicts in Git repository?

I want to resolve merge conflicts in my Git repository. How to do that ?
Spoike
  • 112,352
  • 42
  • 133
  • 155
4913
votes
33 answers

How can I reset or revert a file to a specific revision?

I have made some changes to a file which has been committed a few times as part of a group of files, but now want to reset/revert the changes on it back to a previous version. I have done a git log along with a git diff to find the revision I need,…
Hates_
  • 58,801
  • 6
  • 28
  • 37
1
2 3
99 100