branch

Accidentally pushed commit: change git commit message

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my local repo I have one commit with an incorrect commit message. I've already published the incorrect commit message with git push . Now the remote repo (which is GitHub-hosted) has the incorrect commit message, too. I've already tried git commit --amend , but found that it will not work for me in this situation because I've made additional commits since the incorrect one. How would you fix this situation? 回答1: Easiest solution ( but please read this whole answer before doing this ): git rebase -i In the editor that opens, change pick to

With GitHub how do I push all branches when adding an existing repo?

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I created a new GitHub repo - I want to put my existing repo there. I followed the instructions: cd existing_git_repo git remote add origin git@github.com:acme-org/myprj.git git push origin master This only pushes the master branch to GitHub. How do I push everything (including all branches) in my existing repo to my new GitHub repo? 回答1: Note: git push --all won't push your tags, only your branches. git push --all git push --tags would really push everything . See also " Set up git to pull and push all branches ". Don't forget the --dry-run

You are on a branch yet to be born

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Im have strange problem: $ cd ~/htdocs $ mkdir test $ cd test $ git init Initialized empty Git repository in /home/deep/htdocs/test/.git/ $ git checkout master error: pathspec 'master' did not match any file(s) known to git. $ git checkout -b master fatal: You are on a branch yet to be born $ git checkout origin/master error: pathspec 'origin/master' did not match any file(s) known to git. $ git branch -a (empty this) But this is new local empty repo. Where is master branch? 回答1: As ever, Git is right, it just has a quirky way of saying it:

Git: which is the default configured remote for branch?

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a remote bare repository hub . I work only in the master branch. The last sentence of this error message below makes me wonder: How do I find out which is the "default configured remote for your current branch" ? And how do I set it? [myserver]~/progs $ git remote -v hub ~/sitehub/progs.git/ (fetch) hub ~/sitehub/progs.git/ (push) [myserver]~/progs $ git branch -r hub/master [myserver]~/progs $ git remote -v hub ~/sitehub/progs.git (fetch) hub ~/sitehub/progs.git (push) [myserver]~/progs $ cat .git/HEAD ref: refs/heads/master

git branch: gh-pages

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a repo on GitHub. Recently I have discovered GitHub's pages and I want to use them. I would like to create this new branch and then, when I need to, either commit on master branch or on gh-pages branch. How can I do this? Do I have to create another folder inside my repo? 回答1: You might find this tutorial useful: Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster") . To me this approach seems simpler then doing a git checkout gh-pages each time you want to edit

git - create local branch from existing remote branch

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to create branch from existing remote branch (lets say remote-A)and commit the changes to repo. I have used below commands to create local branch from existing remote-A $git checkout remote - A git branch master * remote - A Now I have created local-B from Remote A using below command git branch local - B git checkout local - B How to make sure the changes I have on local-B is on top of remote-A so that when i do the push on remote repo for branch local-B is on top of remote-A? 回答1: you want to create branch on base of

In Git, local branches can track one another - how is this useful?

独自空忆成欢 提交于 2019-12-03 08:32:26
问题 I heard that in Git , you can let a local branch A track another local branch B . Why would someone want to do that? 回答1: The main things that come to mind for having a local branch track another local branch are (1) more informed messages from Git regarding a branch being ahead/behind of the tracked branch and (2) trigger hooks. One area Git displays more information is when creating a branch. Creating a basic branch looks like the following: $ git co -b A master Switched to a new branch 'A'

Is there a way to limit an integer value to a certain range without branching?

回眸只為那壹抹淺笑 提交于 2019-12-03 08:32:22
问题 Just out of curiosity. If I have something like: if(x < 0) x = 0; if(x > some_maximum) x = some_maximum; return x; Is there a way to not branch? This is c++. Addendum: I mean no branch instructions in the assembly. It's a MIPS architecture. 回答1: There are bit-tricks to find the minimum or maximum of two numbers, so you could use those to find min(max(x, 0), some_maximum) . From here: y ^ ((x ^ y) & -(x < y)); // min(x, y) x ^ ((x ^ y) & -(x < y)); // max(x, y) As the source states though, it

GIT: Checkout to a specific folder

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to use something similar to: git checkout -- / but I want to checkout the file to some folder I choose, rather than the overwriting the local /. Any idea? 回答1: As per Do a "git export" (like "svn export")? You can use git checkout-index for that, this is a low level command, if you want to export everything, you can use -a , git checkout - index - a - f -- prefix = /destination/ path / To quote the man pages: The final "/" [on the prefix] is important. The exported name is literally just prefixed with the specified string.

git hook to create staging branch

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am hosting my code on Bitbucket. The webhooks are not adequate to solve my issue, so I am hoping git hooks will work. Since I don't imagine they will work server-side, the git hook should be propagated to each checkout on each developers machine. (I know this might be an issue since its normally a local file, but I can hopefully solve it using information from here ) I want to create a git hook that will push changes to staging branches. Meaning, if I am a user named bob and I want to push to production/master , instead of it pushing to