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 this tag for general programming questions that happen to involve a Git repository.

59 votes
9 answers
547 views
Move existing, uncommitted work to a new branch in Git

I started some work on a new feature and after coding for a bit, I decided this feature should be on its own b

avatar
Chelsea
0 1 0 9
asked 07 September, 2021
57 votes
7 answers
2.4K views
How do I clone a specific Git branch?

Git clone will behave copying remote current working branch into local. Is there any way to clone a

avatar
Tuan
0 1 0 9
asked 07 September, 2021
54 votes
19 answers
474 views
Undoing a git rebase

Does anybody know how to easily undo a git rebase? The only way that comes to mind is to go at it manually:

avatar
Shantay
0 1 0 9
asked 07 September, 2021
53 votes
30 answers
3K views
Delete commits from a branch in Git

I would like to know how to delete a commit. By delete, I mean it is as if I didn't make that commit, an

avatar
Don
0 1 0 9
asked 07 September, 2021
58 votes
22 answers
3K views
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 remo

avatar
Sena
0 1 0 9
asked 07 September, 2021
61 votes
30 answers
958 views
How do I remove a submodule?

How do I remove a Git submodule? By the way, is there a reason I can't simply do git submodule rm whate

avatar
Elicia
0 1 0 9
asked 07 September, 2021
59 votes
25 answers
2.6K views
How to delete a remote tag?

How do you delete a Git tag that has already been pushed?

avatar
Bryan
0 1 0 9
asked 07 September, 2021
54 votes
30 answers
690 views
How do I update or sync a forked repository on GitHub?

I forked a project, applied several fixes and created a pull request which was accepted. A few days later, ano

avatar
Wei
0 1 0 9
asked 07 September, 2021
57 votes
30 answers
957 views
Squash my last X commits together using Git

How can I squash my last X commits together into one commit using Git?

avatar
Tana
0 1 0 9
asked 07 September, 2021
54 votes
30 answers
2.1K views
Undo a Git merge that hasn't been pushed yet

Within my master branch, I did a git merge some-other-branch locally, but never pushed the changes to origin m

avatar
Omar
0 1 0 9
asked 07 September, 2021
61 votes
30 answers
2K views
How to clone all remote branches in Git?

I have a master and a development branch, both pushed to GitHub. I've cloned, pulled, and fetched, but I

avatar
Percy
0 1 0 9
asked 07 September, 2021
54 votes
21 answers
2.5K views
Reset local repository branch to be just like remote repository HEAD

How do I reset my local branch to be just like the branch on the remote repository? I did: git reset --hard

avatar
Stacia
0 1 0 9
asked 07 September, 2021
55 votes
26 answers
2.9K views
How can I determine the URL that a local Git repository was originally cloned from?

I pulled a project from GitHub a few days ago. I've since discovered that there are several forks on GitH

avatar
Roger
0 1 0 9
asked 07 September, 2021
62 votes
30 answers
1.7K views
How to change the URI (URL) for a remote Git repository?

I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved "origin" to a NAS and succ

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
59 votes
30 answers
393 views
How can I add a blank directory to a Git repository?

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

avatar
Venice
0 1 0 9
asked 07 September, 2021
58 votes
16 answers
375 views
How do I push a new local branch to a remote Git repository and track it too?

I want to be able to do the following: Create a local branch based on some other (remote or local) branch (via

avatar
Roger
0 1 0 9
asked 07 September, 2021
55 votes
30 answers
1.6K views
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 w

avatar
Hallie
0 1 0 9
asked 07 September, 2021
56 votes
30 answers
1.1K views
How to resolve merge conflicts in a Git repository

I want to resolve merge conflicts in my Git repository. How can I do that?

avatar
Wilber
0 1 0 9
asked 07 September, 2021
53 votes
30 answers
1.1K views
How do I discard unstaged changes in Git?

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

avatar
Omar
0 1 0 9
asked 07 September, 2021
62 votes
15 answers
2.9K views
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 b

avatar
Dwain
0 1 0 9
asked 07 September, 2021