EzDevInfo.com

git.js

Javascript Git implementation danlucraft

How do I remove local (untracked) files from my current Git branch?

How do you delete untracked local files from your current branch?


Source: (StackOverflow)

Fix merge conflicts in Git?

Is there a good way to explain how to resolve merge conflicts in Git?


Source: (StackOverflow)

Advertisements

Clone all remote branches with Git?

I have a master and a development branch, both pushed to GitHub. I've cloned, pulled, and fetched, but I remain unable to get anything other than the master branch back.

I'm sure I'm missing something obvious, but I have read the manual and I'm getting no joy at all.


Source: (StackOverflow)

Checkout remote Git branch

I am trying to checkout a remote 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. But how can I get this branch?

  • git checkout test does nothing

  • git checkout origin/test does something, but git branch says * (no branch). I am on no branch?

How do I share branches via a public repository?


Source: (StackOverflow)

Make an existing Git branch track a remote branch?

I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch?

I know I can just edit the .git/config file, but it seems there should be an easier way.


Source: (StackOverflow)

How can I add an empty directory to a Git repository?

How can I add an empty directory (that contains no files) to a Git repository?


Source: (StackOverflow)

How do you discard unstaged changes in Git?

How do I discard changes in my working copy that are not in the index?


Source: (StackOverflow)

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

I'd like to move the last several commits I've made to master to a new branch and take master back to before those commits were made. Unfortunately, my Git-fu isn't strong enough yet, any help?

I.e. How can I go from this

master A - B - C - D - E

to this?

newbranch     C - D - E
             /
master A - B 

Source: (StackOverflow)

How do you undo the last commit?

I committed a directory containing .class files instead of a directory containing .java files to Git.

How can I undo this commit?


Source: (StackOverflow)

What are the differences between 'git pull' and 'git fetch'?

What are the differences between git pull and git fetch?


Source: (StackOverflow)

Undo 'git add' before commit

I mistakenly added files using the command

git add file

I have not yet run git commit. Is there a way to undo this or remove these files from the commit?


Source: (StackOverflow)

Delete a Git branch both locally and remotely

I want to delete a branch both locally and on my remote project fork on GitHub.

Successfully Deleted Local Branch

$ git branch -D bugfix
Deleted branch bugfix (was 2a14ef7).

Note: The uppercase -D option is a shortcut for --delete --force. If you want to delete a local branch that must be fully merged in its upstream branch, use -d which is a shortcut for --delete.

Failed Attempts to Delete 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 found.

$ git branch -rd origin/bugfix
Deleted remote branch origin/bugfix (was 2a14ef7).

$ git push
Everything up-to-date

$ git pull
From github.com:gituser/gitproject
* [new branch] bugfix -> origin/bugfix
Already up-to-date.

What do I need to do differently to successfully delete the remotes/origin/bugfix branch both locally and on GitHub?


Source: (StackOverflow)

Revert to a previous Git commit

How do I revert from my current state to a snapshot made on a certain commit?

If I do git log, I get the following output:

$ git log
commit a867b4af366350be2e7c21b8de9cc6504678a61b`
Author: Me <me@me.com>
Date:   Thu Nov 4 18:59:41 2010 -0400

blah blah blah...

commit 25eee4caef46ae64aa08e8ab3f988bc917ee1ce4
Author: Me <me@me.com>
Date:   Thu Nov 4 05:13:39 2010 -0400

more blah blah blah...

commit 0766c053c0ea2035e90f504928f8df3c9363b8bd
Author: Me <me@me.com>
Date:   Thu Nov 4 00:55:06 2010 -0400

And yet more blah blah...

commit 0d1d7fc32e5a947fbd92ee598033d85bfc445a50
Author: Me <me@me.com>
Date:   Wed Nov 3 23:56:08 2010 -0400

Yep, more blah blah.

How do revert to the commit from November 3, i.e. commit 0d1d7fc?


Source: (StackOverflow)

Force Git to overwrite local files on pull

How do I force an overwrite of local files on a Git pull?

The scenario is 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 source control)
  • They are sending the images by mail, later, to me
  • I'm adding the images under the source control and pushing them to Github together with other changes
  • They cannot pull updates from Github because git doesn't want to overwrite their files.

The errors I'm getting are:

error: Untracked working tree file 'public/images/icon.gif' would be overwritten by merge.

How do I force Git to overwrite them? The person is a designer - usually I resolve all the conflicts by hand so the server has the most recent version that they just needs to update on their computer.


Source: (StackOverflow)

View the change history of a file using Git versioning

How can I view the change history of an individual file in Git, complete with what has changed?

I have got as far as:

git log -- [filename]

which shows me the commit history of the file, but how do I get at the content of each of the changes?

I'm trying to make the transition from MS SourceSafe and that used to be a simple right-click → show history.


Source: (StackOverflow)