git-branch

How can I get a list of Git branches that I've recently checked out?

蓝咒 提交于 2019-12-02 22:15:38
When moving between Git branches I sometimes forget the name of a branch I was recently on. How can I display a list of recently checked out branches/tags/commits? Jordan Brough Summary: You can use Git's reflog to show recent movements: git reflog Script: Here's a script you can download and use via git recent from inside any Git repository: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd Details: Here's essentially what the script does to make the reflog output more usable: $ git reflog | egrep -io "moving from ([^[:space:]]+)" | awk '{ print $3 }' | awk ' !x[$0]++' | egrep -v '^

What is a “branch tip” in Git?

这一生的挚爱 提交于 2019-12-02 22:12:23
I'm learning Git and reading the Pro Git book . The term "branch tip" is used sometimes in the book and also here on Stack Overflow, but I can't find the meaning of it. A branch tip is the last commit or most recent commit on a branch. Basically it points to the most up to date code in the branch. 1615903 Using an image from the Pro Git book to illustrate: master , hotfix and iss53 are all "branch tips" here. Kevin's answer is correct, but this might be easier to understand for beginners. 来源: https://stackoverflow.com/questions/16080342/what-is-a-branch-tip-in-git

Add new commit to the existing Git tag

邮差的信 提交于 2019-12-02 22:08:19
I have created a Git tag as v1.1 using git tag -a v1.1 -m 'my version 1.1' and I pushed that tag. Later, I made some changes related to v1.1 . Now when I push new changes and check the git tag using git describe it is showing me v1.1-g2dcc97 . How can I add my new commit to the existing tag? You can't put a new commit into an existing tag without breaking an important Git guideline: Never(*) modify commits that you have published. Tags in Git aren't meant to be mutable. Once you push a tag out there, leave it alone. You can, however, add some changes on top of v1.1 and release something like

Broken branch in git, fatal: your current branch appears to be broken

自作多情 提交于 2019-12-02 22:06:36
Here is my case: I was working on one branch. Pushed new commits to the remote. Switched back to the master branch. But suddenly after typing git checkout master command my computer encountered blue screen of death and an unexpected force shut down happened. After starting back my computer I have checked the status of my current branch and as a result I got each and every file as marked new files. Now, I am stuck at this point and after git log command I am getting error $ git log fatal: your current branch appears to be broken How to solve this problem and recover my branch?. I am working

How to do a “git checkout -b <branchname>” from a remote tag

北城余情 提交于 2019-12-02 21:54:22
I'm trying to create a branch from a remote tag, but it seems there's no way to do it. When I try git checkout -b test origin/deploy where origin is the remote and deploy is the tag I want to check out, but I get fatal: git checkout: updating paths is incompatible with switching branches. Did you intend to checkout 'origin/deploy' which can not be resolved as commit? UPDATE: I've just discovered that git fetch --all -t was not working properly for me. While it downloads all branches, it does not download all tags, so when I checked out deploy it was and old tag. Now I execute git fetch --all &

Why doesn't the graph display a new branch branching off from the master branch, when I create a new branch in terminal?

牧云@^-^@ 提交于 2019-12-02 21:43:06
Why doesn't the graph in Sourcetree display a new branch branching off from the master branch , when I create a new branch called "testing123" in terminal ? Sourcetree recognises the new branch but it doesn't branch off from the master branch in the graph. Why is this happening ? How can I make Sourcetree graph display the new branch branching off from master? It does: it has one new commit done from master . That means you have checked out the new branch testing123 , done one commit and pushed it (hence origin/ testing123 ). You don't see any "branching" because there is no new commit on

git — locking master branch for some users?

耗尽温柔 提交于 2019-12-02 20:39:27
I would like to force other team-members to not work on the master-branch but on a development branch. we have a central git-repository where we push our work into. i would like to know if it's possible to block users from pushing changes to the master-branch but only allow certain users to do so. I would like to have the following "workflow" development is always only done with a development-branch the release-manager is responsible for the master branch and only he is allowed to merge stuff from a development branch into the master and push it to the master-branch on the central repository

Git repository created without a master branch

若如初见. 提交于 2019-12-02 20:35:41
I want to create a new shared git repository for a new project (on a VM). I ran git --bare init from /.../git/new_proj.git , but a master branch is not created in the .../git/new_proj.git/refs/heads directory. I also ran sudo chmod 777 -R on my directory, but it didn't help, and still no master is created after the init command. Edit: I even tried to use git init (without the bare flag), but still the master branch was not created. Google wasn't much help in this matter... Anyone know what the problem is? Something I'm missing? Thanks! torek It's already in the comments on the other answer so

How do I move a commit between branches in Git?

回眸只為那壹抹淺笑 提交于 2019-12-02 20:06:33
I'm sure this is a simple thing that has been asked and answered, but I don't know what terms to search for. I have this: /--master--X--Y A--B \--C--D--E Where I commited C, D, and E (locally only) on a branch, but then I realized that D and E are really independent of C. I want to move C to its own branch, and keep D and E for later. That is, I want this: /--C /--master--X--Y A--B \--D--E How do I yank C out from under D and E? You can use git cherry-pick to grab C, and put it on Y. Assuming Y exists as the tip a branch called branch-Y : $ git checkout branch-Y $ git cherry-pick C So now C is

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

我怕爱的太早我们不能终老 提交于 2019-12-02 18:59:41
问题 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