Questions tagged [git]

Git is an open source distributed version control system originally designed and written by Linus Torvalds. It is generally used to keep track of source code for software projects. As a DVCS, Git provides powerful help with branching, merging, and distributed development.

Git is an open source distributed version control system originally designed and written by Linus Torvalds. It has been designed with some of the following goals:

  • Speed. Multiple patches can be applied quickly even to large repositories.

  • Distributed development. Git can support developers who synchronize with a central shared repository, developers who share changes with each other directly, and everything in between.

  • Non-linear development. Git provides powerful branching and merging help, even across distributed repositories. Multiple merge strategies are employed to make merges as painless as possible.

Git is usually compared with Mercurial and the two share many features. They are the two most popular DVCS packages.

Related Super User questions

Related Stack Overflow questions

2704 questions
308
votes
4 answers

How do I reset 'master' to 'origin/master'?

Can I do the following in a simpler way? git checkout origin/master git branch -D master git branch master git checkout master
Lenik
  • 18,302
271
votes
11 answers

Can you GPG sign old commits?

Git now has the ability to sign commits with git commit -S, which is great, but sometimes I forget the flag to commit, and sometimes I mail myself patches which I apply with am, and that command doesn't have a flag for signing. Is there a way to…
Magnus
  • 4,386
245
votes
5 answers

Pull another Git branch without switching

We recently switched from SVN to Git and at the same time put our live systems into version control (instead of local checkout and file copy to live). On the project I'm assigned to we all access the same repository and to get changes into live we…
user27709
239
votes
7 answers

Change git init default branch name

I'm trying to figure out how to make git init use a different default branch name other than master for the first commit, but I can't find a git config for it or anything that'd allow me to do this (e.g. aliases only work for commands, not branch…
SoniEx2
  • 2,707
157
votes
10 answers

How can I roll back 1 commit?

I have 2 commits that I did not push: $ git status # On branch master # Your branch is ahead of 'faves/master' by 2 commits. How can I roll back my first one (the oldest one), but keep the second one? $ git log commit…
n179911
  • 3,673
130
votes
5 answers

How to amend the last commit to un-add a file?

I have modified two files a, b in the last commit. But file b should not be commited, what's the workflow to amend this?
Lenik
  • 18,302
101
votes
6 answers

git "ping": check if remote repository exists

I'd like to know whether a remote repository exists. Here's what I came up with: git ls-remote -h "$REPO_URL" &> /dev/null Is there any better way?
Jo Liss
  • 4,279
90
votes
5 answers

Using Git across multiple systems without network access

I want to use version control but, due to security reasons, the server I'm working on has no internet access: I can only move files on a USB flash drive. Can I still use Git with this setup? Can I create small patches that I can apply on a Git…
70
votes
4 answers

How can I push a Git repository to a folder over SSH?

I have a folder called my-project inside which I've done git init, git commit -a, etc. Now I want to push it to an empty folder at /mnt/foo/bar on a remote server. How can I do this? I did try, based on what I'd read: cd my-project git remote add…
rich
  • 1,231
69
votes
2 answers

How to filter commits by author in SourceTree?

In the branch view of SourceTree, I see all the commits. I'd like to filter the commits to show only the ones committed by me/someone. How can I do this? Thanks.
67
votes
2 answers

How to overwrite a branch in Git with master

I have an old dev branch that is completely outdated. I don't want to remove it but I do want to replace its contents entirely with the master branch. Meaning, I want dev_branch = master I tried: git merge -s ours dev_branch Didn't work though...
Cornwell
  • 906
52
votes
3 answers

How can I share a git stash?

Is there a way to share a stash in git? I work on a number of machines, and often want to be able to move my current working state from one to another. I'm looking for a way that I can push/pull a stash from one clone to another, and have it appear…
PeterJCLaw
  • 2,654
48
votes
4 answers

Git: How to delete all untracked files?

I'm using Git for version control. Now I want to delete on my local machine all files in the repository that are not tracked. I can use git status to list these files, but how can I delete all of them?
47
votes
3 answers

How to view only the unmerged files in git after a merge failure

While merging some of the files failed to merge. git status shows both the successful and failed merges. How to view only the unsuccessful merge files(conflict). Currently i am using the following command to do this find . -name '*.cpp' -o -name…
Talespin_Kit
  • 3,391
47
votes
1 answer

git: What does an extra item "origin/HEAD" mean

Following the advice of a friend of mine, I started learning git. I read manual (basic sections) and I think understood most regarding commits, branches, setting backward, forward, etc. but when it comes to sync local repository with remote one, I…
Celdor
  • 701
1
2 3
22 23