git-branch

How do I shallow clone a repo on a specific branch?

时间秒杀一切 提交于 2019-11-28 18:13:26
问题 How do I shallow clone a git repository, so that my clone contains only 1 history item, and starts on a specific branch? I know how to do a shallow clone: git clone --depth 1 https://path/to/myrepo.git but not start the clone on a specific branch. 回答1: To clone repo foo.git with branch bar do: git clone --depth 1 https://path/to/repo/foo.git -b bar See the git-clone documentation: https://www.kernel.org/pub/software/scm/git/docs/git-clone.html 来源: https://stackoverflow.com/questions/21833870

Not Possible to switch branch after --skip-worktree

不羁岁月 提交于 2019-11-28 17:48:31
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 overwritten by checkout: path/to/file Please, commit your changes or stash them before you can switch

How can I completely empty the master branch in Git?

妖精的绣舞 提交于 2019-11-28 17:24:39
问题 I would like to completely empty the master branch in Git. For now, I would also like to keep all other branches which have been branched from master. Is this possible and how? 回答1: That's actually called "delete old master branch and create new from scratch" This will create a new master branch pointing to initial commit: git branch -D master git checkout -b master <initial commit hash> This will create a totally new master branch unrelated to whatever you had: git branch -D master git

Relationship between n git branches

拈花ヽ惹草 提交于 2019-11-28 16:52:19
If I have n git branches, how do I easily show the relationship between these branches? Basically I am interested in seeing a tree of a subset of all the branches in my repository. I am however not interested in all the intermediate commits. E.g.: My repository looks like this: o---o--o A / / o--o--o--o--o--o B \ \ \ \ o--o C \ \ \ \ o--o--o--o--o--o D But probably way more complicated. Now I want to see the relationship between branch A, C and D. Something along the lines of: o A / o--o--o \ \ o---o C \ o--o D Or an equivalent overview. Is this possible, and how? (A graphical tool will be

Git merge from someone else's fork

蹲街弑〆低调 提交于 2019-11-28 16:26:14
问题 I have a repository on github, and someone else has forked it and made changes. I want to: Create a new branch Merge their changes into my branch I have created the new branch: git commit -b my_new_branch How do I merge their code into this new branch? This is the branch that I have created: https://github.com/poundifdef/VirginMobileMinutesChecker/tree/widget_toast This is the branch that I want to merge: https://github.com/xbakesx/VirginMobileMinutesChecker What is the best way to do this? I

git push local branch with same name as remote tag

一个人想着一个人 提交于 2019-11-28 16:02:29
I'm trying to push a new local branch product-0.2 to remote where there is already a tag with the same name (but the branch itself does not exist) git push -v --tags --set-upstream origin product-0.2:product-0.2 Pushing to https://****@github.com/mycompany/product.git error: src refspec product-0.2 matches more than one. error: failed to push some refs to 'https://****@github.com/mycompany/product.git' Same with: git push origin product-0.2:/refs/heads/product-0.2 Although the other way around it works, e.g. create a branch product-0.1 , commit on it then apply a tag product-0.1 . Some people

How to use git branch with Android Studio

六月ゝ 毕业季﹏ 提交于 2019-11-28 15:46:47
问题 I am new to git. I have a very simple scenario for using git. I had my first release written with Android Studio. Now I want to work with some new features. What I did so far: enabled the VCS in my Android Studio created a local repository for my project from Android Studio pushed my local repository to my Bitbucket remote repository ( $git push -u origin master ) Now I am confused for the next step: create a feature branch. Should I create a branch in the local repository: $ git branch -

git remote prune – didn't show as many pruned branches as I expected

陌路散爱 提交于 2019-11-28 15:18:52
From the man page: Deletes all stale tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>". So I removed a bunch of branches using git push origin :staleStuff and then ran git remote prune origin However, only one single local branch was pruned. Some of these branches were created by me, some by co-workers. Does this indicate that I wasn't tracking those branches correctly in the first place? When you use git push origin :staleStuff , it automatically removes origin

How do I rename my git 'master' branch to 'release'?

大兔子大兔子 提交于 2019-11-28 15:09:47
We would like to enforce a new policy for our projects that the master branch now be called the release branch to ensure it is more clear as to how the branch should be used. Naturally, we will have develop and release candidate branches as well. I understand I can rename the master branch locally by simply using the following: git branch -m master release However, that is only locally. Even if I push this up to the remote, the HEAD still points to the remote master branch. I want to get rid of the master branch completely and make the default local branch upon initial clone, be release. How

Why call git branch --unset-upstream to fixup?

有些话、适合烂在心里 提交于 2019-11-28 15:09:31
I'm more of a novice when it comes to advanced operations in git. I maintain my blog using the blogging framework Octopress . Though Octopress is not under any development since 2011, it serves my purpose well and so I haven't thought of changing anything so far. FYI, my blog is hosted on Github Pages. Today, while working on a new post, git status showed the following message: On branch source Your branch is based on 'origin/master', but the upstream is gone. (use "git branch --unset-upstream" to fixup) The same message repeated for all the subsequent commands such as git add . , git commit