git-branch

Switching a branch after aborting current changes in git

我是研究僧i 提交于 2019-12-02 16:11:33
I cloned a git repo and then started playing around in its master branch. After a while, I want to ignore the changes I just made (without committing them), and switch to a different branch. However, it stops me from switching because there are uncommitted changes. How do I ignore them without stashing them either? This is what happens: $ git checkout gh-pages error: Your local changes to the following files would be overwritten by checkout: somefile.txt Please, commit your changes or stash them before you can switch branches. Aborting Option 1 git checkout -f gh-pages Option 2 git reset -

How to read git log graph

拈花ヽ惹草 提交于 2019-12-02 16:08:45
In the git community book, it says Another interesting thing you can do is visualize the commit graph with the '--graph' option, like so: $ git log --pretty=format:'%h : %s' --graph * 2d3acf9 : ignore errors from SIGCHLD on trap * 5e3ee11 : Merge branch 'master' of git://github.com/dustin/grit |\ | * 420eac9 : Added a method for getting the current branch. * | 30e367c : timeout code and tests * | 5a09431 : add timeout protection to grit * | e1193f8 : support for heads with slashes in them |/ * d6016bc : require time for xmlschema It will give a pretty nice ASCII representation of the commit

How to work simultaneously on a few branches

穿精又带淫゛_ 提交于 2019-12-02 15:44:18
This is a follow-up on this question on creating branches. It strikes me as odd that I would still work on one repository because the files on my local machine will be a weird mix of different experiments. I would imagine the best-practice method is to duplicate the repository and work in different folders on my computer for each branch -- but I don't know how to set this up. I have my current repository at Documents/San/CompProj so what are the commands I'd use to create a new repository tied to a different branch on a different local folder? Git is fairly new to me so I'd love any

Is there a way to get a visual diff on two branches in SourceTree?

时光怂恿深爱的人放手 提交于 2019-12-02 15:40:57
Does Sourcetree offer a way to visualize differences between git branches? I'm looking for: names of files that have changed diffs between these files Anton Glukhov Use ⌘ (OSX) or CTRL (Windows and Linux) and choose any two commits you like in log view. It does not matter what branch the commits belong to. As a result you will see something like... Displaying all changes between f03a18bf0370c62bb5fb5c6350589ad8def13aea and 4a4b176b852e7c8e83fffe94ea263042c59f0548 ...down below. Gan Another way to do this is to right-click on a branch and select the "Diff against current" context menu command (

Git branch deletion

巧了我就是萌 提交于 2019-12-02 15:39:24
In Git, what does "deletion" of a branch mean? Will it be gone from the repository? Or will it still be navigable to via git branch ? What I really want to do is mark a branch as "dead end", i.e., the branch is so far from master, that nobody should use it as a starting point, though there were some good ideas down that branch, so we'd like to keep it, for reference. You can delete the branch, but tag it first, so that it's history doesn't disappear. This way, the branch doesn't show up in the branch list, which should hopefully deter people from working on it, but the work won't be

How to delete all remote git branches which have already been integrated?

回眸只為那壹抹淺笑 提交于 2019-12-02 15:33:29
At work we are using topic branches which are integrated into a few (3) master branches at some point. Now I'd like to delete all topic branches from my remote repository which have been fully integrated into a master branch. If that's not possible, retrieving a list of local branches which have been integrated would be fine, too. Another answer edited in by someone who thought it's the best (and it looks good) : git branch -r --merged origin/master | grep -v master | grep "origin/" | cut -d "/" -f 3- | xargs -n 20 git push --delete origin Explanation: git branch -r --merged origin/master -r /

Fork from a branch in github

余生长醉 提交于 2019-12-02 15:10:44
Is there a way to fork from a specific branch on GitHub? … For example, moodle has many branches (1.9, 2.0 … and so on). Can a clone be performed of just branch 1.9 and not the master branch always? Is it possible to clone a specific branch onto my PC? I don’t know a native way yet, but you can do it following this recipe: Fork the repository in question (called ‘upstream’) on the GitHub website to your workspace there. Run the GitHub desktop application and clone the repository onto your PC. Use the GitHub desktop application to open a shell in the repository. (The git commands are not

Switch to another branch without changing the workspace files

一世执手 提交于 2019-12-02 14:49:12
I cloned a git repository from GitHub, made some changes and some commits; I made quite a lot and all are quite dirty, so they're not suitable for a pull request. Now I created the branch cleanchanges from origin/master , so it's clean, and I want to commit my changes there as one commit with a nice commit comment. When I am on the local master, I want to switch to my cleanchanges but without changing the files. And then I'm able to commit. How can I switch branches without changing files? I want to make it clear: I have all the changes committed in the local master . There are no uncommitted

Git merge from someone else's fork

孤人 提交于 2019-12-02 14:36:52
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've tried a "pull" and it won't work. I honestly have no idea what I'm doing in gitland, so if there is

How to create the branch from specific commit in different branch

旧时模样 提交于 2019-12-02 14:21:25
I have made several commits in the master branch and then merged them to dev branch. I want to create a branch from a specific commit in dev branch, which was first committed in master branch. I used the commands: git checkout dev git branch <branch name> <commit id> However, this creates the branch from master branch, not the dev branch I expected. The commit id is same in master branch and dev branch. So, how can I distinguish same commit id in different branch? PS: I made an example in github here https://github.com/RolandXu/test_for_branch I used the commands: git checkout dev git branch