git-branch

git branch -r vs git remote show origin

﹥>﹥吖頭↗ 提交于 2019-12-11 20:02:48
问题 So I was looking for a way to see a list of all the branches that exist on the remote, and found the following 2 commands: 1. git branch -r 2. git remote show origin Whats the difference between the 2 commands? 回答1: The git branch command looks at (or, invoked differently, modifies) your own repository's information. For remote-tracking branches ( git branch -r ), this shows what's in your cached copy of what was on the remotes the last time you had your git contact those remotes and get

how to combine commits and push to the remote

≯℡__Kan透↙ 提交于 2019-12-11 18:43:47
问题 At the beginning the local branch is uptodate and now I use git rebase -i HEAD~3 and modify the pick of the two newest commits to fixup to combine 3 commits at the local branch,and now I want to push the local branch to the remote. And I only want to show a combined commit at the remote. However,after combined the local branch falls behind with remote by two commits and I cannot push directly. How can I deal with it? 回答1: DISCLAIMER : git push --force is dangerous; use it at your own risk. If

GIT - Fail to checkout to other branch when nothing to commit - when file is in gitignore

我们两清 提交于 2019-12-11 16:47:28
问题 Trying to checkout to another branch I have a .gitignore file with .someFile trying to checkout to another branch fails even when i dont have any changes dev@cool:~/proj/source$ git status # On branch master nothing to commit, working directory clean dev@cool:~/proj/source$ git checkout someBranchName error: Your local changes to the following files would be overwritten by checkout: .someFile Please, commit your changes or stash them before you can switch branches. Aborting dev@cool:~/proj

Understanding git branch all

て烟熏妆下的殇ゞ 提交于 2019-12-11 10:26:01
问题 What does the the arrow (->) mean here: * development master production remotes/origin/HEAD -> origin/production remotes/origin/development remotes/origin/master remotes/origin/production I'm just trying to get a real handle on git, so I'm diggin' deep and finding out that the further I go, the less I know about git, haha. 回答1: remotes/origin/HEAD -> origin/production means remotes/origin/HEAD is pointing to origin/production origin/HEAD is not a self-contained branch. It is just a pointer to

Remove Git submodule from branch

微笑、不失礼 提交于 2019-12-11 10:16:48
问题 Is there a posssiblity to have a submodule on one branch and not to have it on another? Is it possible to remove a submodule on a specific branch but to have it on other branches? Or add a submodule to experimental branch only. 回答1: Your submodules are defined by your .gitmodules file, which is just another file in your repository, version like everything else. So if you change it in a branch, it's changed. Thus, all your questions can be answered 'yes'. 来源: https://stackoverflow.com

Git clean branch to save only my changes and changes from master

妖精的绣舞 提交于 2019-12-11 09:17:54
问题 I have a branch, where I did some changes, but I'd originally mistaken and create it from wrong branch, so I have many different changes I don't want to have in it. So how can I clean it so I only have changes I've done and changes from master branch? 回答1: You can create a new branch from master and then cherry-pick the changes you have made into the new branch. Find the commit hashes for every commit you want to save. Then: git checkout master git checkout -b <new branch name> git cherry

Branch specific lines in Git

妖精的绣舞 提交于 2019-12-11 08:41:20
问题 Sorry that my question is so vague, but I don't really know how to describe the situation best. In my repository the README file contains a link, which has the branch name master or develop in it for the respective branches (only those two branches are affected, I don't really care how it is handled for different branches). What I want now, is that if I merge develop into master this difference is preserved. What I did up to now, was using git merge --no-commit develop And manually fix the

Git not pushing correctly for Github gh-pages

混江龙づ霸主 提交于 2019-12-11 07:27:37
问题 when I git push, it says "everything up to date", but when I do git branch -vv, it says this: MacBook-Pro:gitpracticing c$ git branch -vv gh-pages 19f1cfc made after dinner * ghpages 4aacdb1 [origin/gh-pages: ahead 11] yea master 4aacdb1 [origin/gh-pages: ahead 11] yea MacBook-Pro:gitpracticing corey$ even though I do git push, the origin/gh-pages branch is still ahead by 11. How do I fix this? So I have 3 branches: "gh-pages", "ghpages", and "master". I notice that when I'm on the gh-pages

merge branch that was created from old commit to master

ⅰ亾dé卋堺 提交于 2019-12-11 07:09:40
问题 I created a new branch from old master-commit. When trying to merge it with master using git checkout master git merge newbranch I am getting Already up to date although it is a different code. Of course there is an option to go back several commits (using git reset ) but this is not what I am looking for. I want to push / merge the newly created branch to master. What is the best way to do that? 回答1: You need to go back to the master branch ( git checkout master ) and then merge in your new

switching branches in git - when will i get “You have local changes cannot switch branches.”? [duplicate]

大憨熊 提交于 2019-12-11 02:15:23
问题 This question already has answers here : Closed 8 years ago . Possible Duplicates: git: Switch branch and ignore any changes without committing. Git branches behaving strangely I know that the general recommendation is to have a clean status before switching branches in git. ( stash or park-commit ). I'm trying to understand when will I get "You have local changes cannot switch branches" , I can't follow the logic : I have a repo, with a file called version.txt, contains the text "1" : git