🌐
Git
git-scm.com › docs › git-branch
Git - git-branch Documentation
Move/rename a branch, together with its config and reflog. ... Shortcut for --move --force.
Discussions

Am I using git push --force the right way?
That sounds like the right approach, and the one I use. After the rebase, your local dev1 history is different than the remote's dev1 branch. That is expected after a rebase, because a rebase changes history. Though I would recommend that you use --force-with-lease instead of --force to avoid clobbering any commits that you do not have locally which might have been pushed to the dev1 branch. Just a good habit. More on reddit.com
🌐 r/git
9
7
October 4, 2018
Branching for dummies?
Well I don't want to commit anything yet. Here's your problem. Branches are nothing else than fancy (movable) names for commits. It's best if you think of Git as a Graph (specifically, a DAG – directed acyclic graph) of commits, and branches just tell you where in that graph you are. When you create SecondBranch, it points at exactly the same content as FirstBranch – and without you doing a commit, that won't change. What complicates this further is that your file is untracked, meaning it was never part of a commit nor added to the index. Git just doesn't care about untracked files, as they're not part of Git's object storage. From Git's point of view, they're just "accidentially" in the same directory. When you switch branches (via switch or checkout), Git deletes your working directory and replaces it with the contents of the commit you're changing to. BUT: it leaves untracked files alone. What if you had edited a tracked file instead and then attempted to change your branch? If both branches are identical (see first paragraph), that's possible. If however you attempt to checkout a different commit, while you have un-committed changes in a tracked file, Git will prevent that and warn you. In that case, you'll have to commit or stash your changes first. Btw, I'd strongly encourage you to read the Git Pro Book, at least the first 5 chapters. Yes, it's long and you probably won't understand half of it on your first read-through, but it's worth it. A thorough understanding of something cannot be developed by just reading an "idiot's guide" or "learn in 10min". imho. Also, take a look at "The Git Parable" (see sidebar). It's teaches the fundamental concepts of Git (why it is the way it is), a short and very helpful read. More on reddit.com
🌐 r/git
14
4
December 2, 2021
🌐
Brandon Pugh's Blog
brandonpugh.com › til: today i learned... › git branch --force
Git branch --force | Brandon Pugh's Blog
August 16, 2023 - Today I learned about the --force parameter of git branch which will take an existing branch and point it to a different commit. This is another handy alternative to git reset --hard for some common scenarios.
🌐
Reddit
reddit.com › r/git › am i using git push --force the right way?
r/git on Reddit: Am I using git push --force the right way?
October 4, 2018 -

Hello everyone,

I would like to know if I'm using git push --force the right way. Here is my scenario:

  1. I branched off master (let's call my branch dev1) which I did some work on and then pushed up remotely

  2. A ton of work has been done on `master` I've been working on dev1 locally

  3. I want my local dev1 branch to have all the updated changes that master has so I rebased

  4. At this point, my local dev1 is way out of sync with remote dev1. Git is saying if I want to sync them up then I need to do a git pull (but I definitely don't want to pull the changes down from the remote branch to my newer, local branch).

Assuming no one else works on dev1, am I supposed to git push --force to sync local `dev1` to remote `dev1`? If not, what are my alternatives?

🌐
Graphite
graphite.com › guides › git-force-checkout
Git force checkout
Switching branches when local changes conflict with the branch: If uncommitted changes in your current branch would be overwritten by checking out another branch, without the --force flag, Git will block the action to prevent data loss.
🌐
Medium
medium.com › @lada496 › force-merge-in-git-796a1cb997e8
Force merge in Git. This is the last way to deal with merge… | by Lada496 | Medium
October 26, 2022 - // go to feature branch git switch(or checkout) feature// create new branch git branch feature · // force merge git merge -s ours main · git merge feature ·
Find elsewhere
Top answer
1 of 2
99

If you want all changes from master in dev_branch, then:

git switch dev_branch
git reset --hard master

If you have dev_branch pushed to a remote already, you have to do:

git push --force

To force-push the branch to the remote. Warning: This will break the history of the branch for people who cloned it before! Then, other people will have to do a git pull --rebase on the dev_branch to get the changes.


You can also rename the dev branch to something old and then make a new branch from master with the same name:

git branch -m dev_branch old_dev_branch
git branch -m master dev_branch

Or, use the ours strategy — not sure why it wouldn't work for you:

git checkout master
git merge -s ours dev_branch
git checkout dev_branch
git merge master
2 of 2
1

Why do that? You can delete the branch if it isn't needed anymore (But why? Branches cost next to nothing.). Or you can rename it:

git branch -m dev_branch obsolete_dev

Or you could do this to delete it:

git branch -D dev_branch

Now create a new branch off master (assuming you are on it):

git branch dev_branch

See git branch --help for further options (setting up remotes and all that jazz).

If you now have new branches, you'll have to synchronize with any peer repositories.

Best way to avoid hassle: Have an "active" development branch, if it goes stale, abandon it and create a new one. No history lost that way (could prove crucial sometime).

Have e.g. a branch for each major version, develop on branches off those to fix version bugs, master forges ahead. Use cherry-pick and perhaps merges to port fixes to older versions.

🌐
DataCamp
datacamp.com › tutorial › git-push-force
Git Push Force: How it Works and How to Use it Safely | DataCamp
July 24, 2025 - When you do this, your local branch ... which protects the remote branch from loss of work. Using git push --force tells Git to skip the safety check and overwrite the remote branch with what is in your local branch....
🌐
Better Stack
betterstack.com › community › questions › how-to-properly-force-git-push
How Do I Properly Force a Git Push? | Better Stack Community
Replace your-branch-name with the name of the branch you want to push forcefully. Alternatively, you can use the -f shorthand for force push: ... Git will update the remote branch with your local changes, overwriting any conflicting changes ...
🌐
Git
git-scm.com › book › en › v2 › Git-Branching-Branch-Management
Git - Branch Management
If you really do want to delete the branch and lose that work, you can force it with -D, as the helpful message points out.
🌐
Git
git-scm.com › book › en › v2 › Git-Branching-Branches-in-a-Nutshell
Git - Branches in a Nutshell
Some people refer to Git’s branching model as its “killer feature,” and it certainly sets Git apart in the VCS community. Why is it so special? The way Git branches is incredibly lightweight, making branching operations nearly instantaneous, and switching back and forth between branches ...
🌐
Git
git-scm.com › book › ms › v2 › Appendix-C:-Git-Commands-Branching-and-Merging
Git - Branching and Merging
It can list the branches you have, create a new branch, delete branches and rename branches.
🌐
Codecademy
codecademy.com › learn › fscp-git-and-github-part-ii › modules › fscp-git-branching › cheatsheet
Git and GitHub, Part II: Git Branching Cheatsheet | Codecademy
In Git, the main project is completed on the main branch. Making your first commit in a new git repository will automatically create a main branch. Create new branches from the main branch to develop new features for a project.
🌐
Reddit
reddit.com › r/git › branching for dummies?
r/git on Reddit: Branching for dummies?
December 2, 2021 -

I need someone to explain this to me because I feel like an idiot and I'm getting frustrated. This is at least the third time I've tried to get even a rudimentary understanding of git and it just doesn't take.

I'm walking through this guide because based on the title it should be my speed: https://medium.com/@rukeeojigbo/git-basics-an-idiots-guide-99445a56bd65

Switching between branches sounds simple enough. So I create FirstBranch and edit a text file in it. Cool, git status lets me know there are new changes it detected. Well I don't want to commit anything yet, I want to continue playing around with branches. So I create SecondBranch and check the text file. The text file has the same content that it did on FirstBranch. I guess that makes sense since we were sitting in FirstBranch when we created SecondBranch. I edit the text file with some blurb about it being in SecondBranch. Branches are basically just folders I can swap between right, so let's hop back over to FirstBranch and see that other version of the text file that doesn't have any references to SecondBranch. Oh it does have references to SecondBranch, which means this doesn't work at all the way I thought it did. Now I'm just confused and frustrated.

I need an idiot's guide to git and I'm beginning to think one doesn't exist because it's simply too complex of a tool for me and I'm going to just go back to manually making dated copies of the project folder every time I need to snapshot progress.

Top answer
1 of 6
7
I would recommend playing with https://learngitbranching.js.org/
2 of 6
5
Well I don't want to commit anything yet. Here's your problem. Branches are nothing else than fancy (movable) names for commits. It's best if you think of Git as a Graph (specifically, a DAG – directed acyclic graph) of commits, and branches just tell you where in that graph you are. When you create SecondBranch, it points at exactly the same content as FirstBranch – and without you doing a commit, that won't change. What complicates this further is that your file is untracked, meaning it was never part of a commit nor added to the index. Git just doesn't care about untracked files, as they're not part of Git's object storage. From Git's point of view, they're just "accidentially" in the same directory. When you switch branches (via switch or checkout), Git deletes your working directory and replaces it with the contents of the commit you're changing to. BUT: it leaves untracked files alone. What if you had edited a tracked file instead and then attempted to change your branch? If both branches are identical (see first paragraph), that's possible. If however you attempt to checkout a different commit, while you have un-committed changes in a tracked file, Git will prevent that and warn you. In that case, you'll have to commit or stash your changes first. Btw, I'd strongly encourage you to read the Git Pro Book, at least the first 5 chapters. Yes, it's long and you probably won't understand half of it on your first read-through, but it's worth it. A thorough understanding of something cannot be developed by just reading an "idiot's guide" or "learn in 10min". imho. Also, take a look at "The Git Parable" (see sidebar). It's teaches the fundamental concepts of Git (why it is the way it is), a short and very helpful read.
🌐
CloudBees
cloudbees.com › blog › git-create-branch
Git Create Branch: 4 Ways to Do It
October 2, 2018 - Unsurprisingly, you create branches in Git by using the branch command. Like many other Git commands, like "pull" or "push," "branch" is very powerful and flexible. Besides creating branches, it can also be used to list and delete them, and you can further customize the command by employing a broad list of parameters.
🌐
Learn Git Branching
learngitbranching.js.org
Learn Git Branching
Terminal – Learn Git Branching · $ Git Hg · × ·
🌐
Jvns.ca
jvns.ca › blog › 2024 › 03 › 22 › the-current-branch-in-git
The "current branch" in git
So let’s talk about a few git scenarios and how each of these definitions plays out in each of them. I used git version 2.39.2 (Apple Git-143) for all of these experiments. Here’s the most normal situation: you check out a branch.
🌐
Atlassian
atlassian.com › git › tutorials › using branches › git checkout
Git Checkout | Atlassian Git Tutorial
Git branching intro. Create, list, rename, delete branches with git branch. git checkout: select which line of development you want and navigate branches
🌐
Alpha Efficiency.™
alphaefficiency.com › git-force-checkout
How to Force Git Checkout | Alpha Efficiency.™
Let’s take a look at the multiple purposes or reasons why you might have to use Git force checkout: Switch between branches when local changes create conflict: Git blocks any checkout action if switching between brands involves overwriting any uncommitted modifications in the current branch.
Published   April 28, 2022
🌐
Atlassian
atlassian.com › git › tutorials › using branches
How to Create a Branch in Git? | Atlassian Git Tutorial
December 15, 2025 - This document is an in-depth review of the git branch command and a discussion of the overall Git branching model. Branching is a feature available in most modern version control systems. Branching in other VCS's can be an expensive operation in both time and disk space.