git-branch

git - create local branch from existing remote branch

ε祈祈猫儿з 提交于 2019-12-05 19:04:43
问题 I want to create a branch from an existing remote branch (let's say remote-A) and then commit the changes to repo. I have used the below commands to create a local branch from the existing remote-A $git checkout remote-A git branch master * remote-A Now I have created local-B from Remote A using the below commands git branch local-B git checkout local-B How do I make sure the changes I have on local-B are on top of remote-A so that when I push local-B to the remote repo, the changes are on

Check if a git branch is ahead of another using a script

自古美人都是妖i 提交于 2019-12-05 18:51:47
I have branch1 and branch2 and I want some sort of: git branch1 isahead branch2 That will show if branch1 has commits that branch2 doesn't have (and possibly specify those commits too). I can't check diff cause branch2 is ahead of branch1 (has commits that branch1 doesn't have). Is there a way? I looked through git diff and couldn't find anything You can use git log branch2..branch1 If branch1 has no commit ahead of branch2 , output will be empty. You can also use git rev-list --count branch2..branch1 This will show the number of commits ahead Source You have already got an answer. So I'll add

Git: how to set remote in existing repo

不羁岁月 提交于 2019-12-05 16:19:18
One question please I have a project on git with differents branches: Master Pre Dev .... I've installed my project files in another server by FTP (not by git pull or git clone) ir order to create a dev enviroment. The folder of the project in dev enviroment don't have a git repo. Can I set that this folder is a existing repo (dev branch) without do a git pull or git clone? Go to your project folder. Add a remote origin with your existing repository URL. $ git init $ git remote add origin <existing-repo-url> $ git checkout -b dev # checkout a new branch 'dev' You need to stash (clean working

Git pull reverted commits in master?

删除回忆录丶 提交于 2019-12-05 13:42:37
A colleague, whom we'll call Aaron, was assigned to renovate a section of a website as a long-term project. He created a new Git branch, called aaron . All his changes were made on this branch. While he was working, I continued to maintain the site as a whole, committing my changes to master . Eventually, Aaron merged his branch into master . This somehow reverted all of the commits I'd made to master between the time of the merge and the time when the aaron branch was first created. If I type git show <hash of merge commit> , I can see diffs for every file I changed while Aaron was working on

Should we remove a remote Git branch after merging to master?

时光怂恿深爱的人放手 提交于 2019-12-05 13:12:56
I would like to know if it's better to delete your branch after merging to master or if we should continue to work on the same separate branch during all the project. i.e If we are 3 members in the group, each of us create his own branch and works on it during the duration of the project. We all commit in the master branch and pull before we start working on something else. In that way, we know who's working on which branch and we don't get confuse. Thanks. So there are tons of literature about how to manage your branches but really I think it comes down to how you want to manage things within

How do I safely delete a remote git branch?

微笑、不失礼 提交于 2019-12-05 11:45:55
问题 To delete a local branch in git I use git branch -d , but how do I safely remove a remote branch? I would like to delete it only when the remote branch is merged to my current branch . 回答1: The answer is partly covered here: How can I know in git if a branch has been already merged into master? While that post copes with local branches, you could find remote branches that are merged or not using git branch -r --merged to detect all remote branches that are already merged into the current git

git remove files from only one branch

那年仲夏 提交于 2019-12-05 10:06:50
问题 when I delete files from one branch it deletes from all branches. what can I do? 回答1: when deleting a file with git and persisting that project state ( git commit ) it will only be deleted in that commit and its children (speaking: in that branch). when merging that branch into another branch it might well be possible, that the file is going to be deleted (unless changed in the other branch). when deleting a file, not committing it and then switching branches, git will apply your current set

how do I remove a remote branch when I get an error?

笑着哭i 提交于 2019-12-05 09:55:09
I have tried the following command and it fails. git push origin :next remote: error: denying ref deletion for refs/heads/next To blah.git ! [remote rejected] next (deletion prohibited) error: failed to push some refs to 'blah.git I am using gitolite and cannot find any of this error message in the hooks. How can I disable this so that I can delete or rename this remote branch? When I run git branch -r -d origin/next, it appears to go away, but the next git pull brings it right back. Make sure in your gitolite config, you have the rewind flag on so instead of RW use RW+ . That will allow you

How to create branch-specific files on GitHub

这一生的挚爱 提交于 2019-12-05 06:39:48
I would like to have branch-specific files with the same name. I need to be able to merge from my development branch to master without changes made in this file. For example: Let's assume that I would like to have two different readme.md files. In one I would like to have content: MASTER and in another DEV . But if I try to do it, while creating pull-request GitHub will try to merge this file, which is exactly my problem. I don't want GitHub to merge this file each time I make changes. What would be the best way to solve this problem? Let's say project is a name of the branch to be merged, and

Can not create a local and remote branch (tracking) at the same time

不羁的心 提交于 2019-12-05 01:38:27
From Pro Git : you can set up other tracking branches if you wish — ones that don’t track branches on origin and don’t track the master branch. The simple case is the example you just saw, running git checkout -b [branch] [remotename]/[branch] $ git checkout --track origin/serverfix Branch serverfix set up to track remote branch refs/remotes/origin/serverfix. Switched to a new branch "serverfix" $ git checkout -b sf origin/serverfix Branch sf set up to track remote branch refs/remotes/origin/serverfix. Switched to a new branch "sf" My understanding is that this presents a way to create a local