git-branch

git switch branch without discarding local changes

心不动则不痛 提交于 2019-11-28 02:47:59
Alright, lets say one day we make happen to make a bunch of modifications and when we go to commit them we notice we were working on the wrong branch. How can we force git to switch branches without discarding local changes . I'm probably going to go about this in a naive way while I wait a reply, but I would like to know if theres a correct procedure as I'd be lying if I said this hasn't happened to me before... Backup changed repo git reset --hard git checkout right-branch Restore changes git commit -m "changes" There are a bunch of different ways depending on how far along you are and which

Why does git-rebase give me merge conflicts when all I'm doing is squashing commits?

给你一囗甜甜゛ 提交于 2019-11-28 02:42:09
We have a Git repository with over 400 commits, the first couple dozen of which were a lot of trial-and-error. We want to clean up these commits by squashing many down into a single commit. Naturally, git-rebase seems the way to go. My problem is that it ends up with merge conflicts, and these conflicts are not easy to resolve. I don't understand why there should be any conflicts at all, since I'm just squashing commits (not deleting or rearranging). Very likely, this demonstrates that I'm not completely understanding how git-rebase does its squashes. Here's a modified version of the scripts I

Git: How do I list only local branches?

a 夏天 提交于 2019-11-28 02:31:49
git branch -a shows both remote and local branches. git branch -r shows remote branches. Is there a way to list just the local branches? Just git branch without options. From the manpage: With no arguments, existing branches are listed and the current branch will be highlighted with an asterisk. just the plain command git branch shortduck git branch -a - all branches. git branch -r - remote branches only. git branch -l or git branch - local branches only. If the leading asterisk is a problem, I pipe the git branch as follows git branch | awk -F ' +' '! /\(no branch\)/ {print $2}' This also

Commit a file to a Different Branch Without Checkout

血红的双手。 提交于 2019-11-27 21:05:21
Is it possible to commit a file in a git branch with out checking out that branch? If so how? Essentially I want to be able to save a file in my github pages branch without switching branches all the time. Any thoughts? Update: It's not possible to do what I want (see comments below for use case). What I ended up doing is programmatically cloning my current directory to a tmp directory, then checking out my branch in that tmp directory (doesn't affect my working directory) and committing my files to the tmp directory clone. When I'm done, I push back to my working directory and delete the tmp

Not Possible to switch branch after --skip-worktree

懵懂的女人 提交于 2019-11-27 20:11:48
问题 WHAT I WANT TO DO I have a file which contains sensitive datas so I don't want to push content of this file to remote server. WHAT I DID? To achieve this, I made a commit when the file was empty and pushed this empty file to server (GitHub). And then fill the file with sensitive datas and applied git update-index --skip-worktree path/to/file . But I didn't made any commit. Now I'm trying to switch my branch but I'm getting this error : error: Your local changes to the following files would be

Show the original branch for a commit

感情迁移 提交于 2019-11-27 19:38:00
I've used git-blame to find a particular commit. Now I want to find the branch that it originally came from. (From there, I'll use the branch name to find the particular ticket) Let's define "original branch" as "the branch to which the commit was made before the branch was merged into any other branch". Like the others said, if the branch you are looking for isn't local to the repository on which you are blaming this commit (e.g. a branch only in the personal repo of a distant developer), you are screwed. But assuming that sought-after branch is something you can see, and that of course you

Sync GIT and ClearCase

拜拜、爱过 提交于 2019-11-27 19:31:47
I am currently working on ClearCase and now migrating to GIT. But we need this migration in a way that all work will be done in GIT and the data will be synced backed to ClearCase stream. We will have the same branch names and stream names in both GIT and CC, so scripting shouldn't be a problem. The problem here is, Can someone suggest which is the best model to sync CC and GIT Have all the Vobs in CC as single repo in GIT, and have the major stream in CC as various branches in GIT. - Single GIT repo (VOBS) and many branches (CC streams). - This takes up less space as VOBs are kept as single

Push a branch of a git repo to a new remote (github), hiding its history

泄露秘密 提交于 2019-11-27 19:16:34
问题 My organisation is preparing to release an open-source version of our software using github, however I'm not sure the best way to approach this: We have two branches master and release , master contains some proprietary components that we have decided not to release, and release contains the cleaned-up version that we want to distribute. The problem is, if we just push the release branch to github, the proprietary components can be retrieved by looking through the revision history. I was

git pull all branches from remote repository

梦想与她 提交于 2019-11-27 18:23:07
How do I pull all of the remote branches to my own repository? if I type: git branch -a I get a long list of branches, but if I type: git branch I see only 2 of them. How do I pull ALL branches into my local list? I know I can do: git checkout --track origin/branch-name but that pulls and checks out only one branch at a time. Any way to get it all done at once without that whole tedious work of running git checkout --track origin/branch-name over and over and over again? ps. I tried following commands, none of them made remote branches appear in my git branch list: git fetch --all git remote

How do I “move” my commits from “no branch” to an actual branch?

强颜欢笑 提交于 2019-11-27 17:59:32
I made a mistake, and started making commits "to the last tag", which lands my commits in "no branch". They should have been applied at the head of an already existing branch. I have not pushed my changes yet. I've found a few other question for when commits are in the wrong branch, but now I have no branch, so I don't know how to handle this. Preferably, I would like to erase my mistake entirely, and "move" my changes to the end of the right branch. If I must leave my mistake in the history, I need to merge them in atleast. You are currently in a detached HEAD state. To resolve that, all you