git-branch

Git pulling a branch from another repository?

不羁岁月 提交于 2019-12-02 13:57:33
I have a local git repository which is a clone of a repository on github. Someone has forked the repository and made changes in a new branch on a new repository. I want to move this new branch into my repository (locally to work on it first before merging with the master). I tried creating a new branch and then pulling from the forked repository but it complains because the new branch is a copy of the master branch as well as the local file changes, so it says error: Your local changes to the following files would be overwritten by merge . So how can I pull the branch in the other repository

How do I make a branch point at a specific commit?

烈酒焚心 提交于 2019-12-02 13:54:53
In Git, I understand that a branch is a pointer to a commit. How do I make a specific branch point to a specific commit? Say I want to make master point at 1258f0d0aae... , how do I do that? Mark Longair You can make master point at 1258f0d0aae this way: git checkout master git reset --hard 1258f0d0aae But you have to be careful about doing this. It may well rewrite the history of that branch. That would create problems if you have published it and other people are working on the branch. Also, the git reset --hard command will throw away any uncommitted changes (i.e. those just in your working

Rename a Git branch locally and remotely? [duplicate]

旧城冷巷雨未停 提交于 2019-12-02 13:54:50
This question already has an answer here: Rename master branch for both local and remote Git repositories 15 answers Is there a way to rename a Git branch locally and push it to the remote branch, even if there are already many commits pushed to the remote branch? Or, is it necessary to create a new local branch, delete the old local branch, and then repeat the operation on the remote repository? Rémi Becheras Yes, the feature move exists to rename the branch locally git branch --move <old_name> <new_name> but to push it, you must delete the old and push the new git checkout <new_name> git

When to delete branches in Git?

允我心安 提交于 2019-12-02 13:50:00
Suppose we have an application that's stable. Tomorrow, someone reports a big ol' bug that we decide to hotfix right away. So we create a branch for that hotfix off of "master", we name it "2011_Hotfix", and we push it up so that all of the developers can collaborate on fixing it. We fix the bug, and merge "2011_Hotfix" into "master" as well as into the current development branch. And push "master." What do we do with "2011_Hotfix" now? Should it just sit out there as a branch forever until the end of time or should we now delete it, since it has served its purpose? It seems unclean to just

How do I fetch a branch on someone else's fork on GitHub? [duplicate]

依然范特西╮ 提交于 2019-12-02 13:49:37
This question already has an answer here: How to pull remote branch from somebody else's repo 6 answers I've forked from a repo on GitHub. I want to get the code from a branch on another user's fork. Must I clone this user's whole repo to a separate local repo or can I do something like git checkout link_to_the_other_users_branch ? $ git remote add theirusername git@github.com:theirusername/reponame.git $ git fetch theirusername $ git checkout -b mynamefortheirbranch theirusername/theirbranch Note that there are multiple "correct" URIs you can use for the remote when you add it in the first

How do I push a local Git branch to master branch in the remote?

断了今生、忘了曾经 提交于 2019-12-02 13:46:05
I have a branch called develop in my local repo, and I want to make sure that when I push it to origin it's merged with the origin/master. Currently, when I push it's added to a remote develop branch. How can I do this? $ git push origin develop:master or, more generally $ git push <remote> <local branch name>:<remote branch to push into> Eugene Sajine As people mentioned in the comments you probably don't want to do that... The answer from mipadi is absolutely correct if you know what you're doing. I would say: git checkout master git pull # to update the state to the latest remote master

How to compare two git branches and filter the differences by commit message?

霸气de小男生 提交于 2019-12-02 12:26:00
I have a release branch named release/X.X.X.X which contains all feature branches I want to deploy to production. The release branch is made on top of master which is the current state of production. On every release day I make sure our release branch contains only those changes planned for the release. I use this command to compare the release and master branch: git log release/X.X.X.X ^master --no-merges . I then manually check the commits for keywords like "SHR-1234" which represent ticket numbers in our ticket management system. I need to compare each commit with a list of ticket numbers

Display GitHub README screenshot stored in a different branch, both on GitHub and locally

ⅰ亾dé卋堺 提交于 2019-12-02 08:19:58
Update: This is the GitHub test repository for this question. I'm storing a screenshot ( screenshot.png ) in a separate Git branch ( assets ), to be used in a README.md file (on the master branch). To see the image on GitHub, I have to link to: /../assets/screenshot.png or ../assets/screenshot.png However, this does not work when viewing the README file locally, the image is not displayed (such as when using the Markdown preview feature in VS Code or Atom). I have even used the git worktree feature, to check out the assets branch in the assets subdirectory: git worktree add -B assets assets

Can I pull only certain files from another git repository?

前提是你 提交于 2019-12-02 05:55:36
问题 For instance, suppose I have Repository 1 and Repository 2. Repository 1 has a file /a/b/c/d . Would it be possible for me to import this file into Repository 2 as /e/f/g/h ? The reason being that I want to pull in changes from an experimental branch from a different git repository. I tried merging everything together, but there were a ton of conflicts (of every kind). Therefore, I doubt that I can merge the entire branch in, but I would like to try to bring in as much as I can. Is there any

How to protect “master” branch in GitHub?

与世无争的帅哥 提交于 2019-12-02 04:03:33
问题 We are a team of a few people. Everyone works on a feature branch and merges his stuff through GitHub UI into master when one is ready. Now is it possible to prevent direct pushes to master , but instead create a pull request whenever a new feature is ready to be merged? Additionally it would be awsome to restrict merges to a subset of devs only. 回答1: Additionally it would be awsome to restrict merges to a subset of devs only. You can restrict pushes to a branch in an Organization to specific