git-checkout

Git: Checkout old version of directory under new name

元气小坏坏 提交于 2020-06-28 05:50:31
问题 How do I check out a previous version of a directory under a new name? (I have and always had a directory foo in my repo. I want to create a directory foo_old in my current working tree whose contents are those of HEAD~2:foo . I need both versions at the same time, to make sure they give the same results, testing this requires quite a bit of code and requires having both results available at the same time (the results are not simply integers, say), so I cannot simply checkout HEAD~2

Get previous branch name

与世无争的帅哥 提交于 2020-06-27 09:50:32
问题 I really like git checkout - to move to my previous branch. But sometimes I only need to know what my previous branch name is. How could I ask Git that? For example, if git checkout - moves to branch "prev", I want the command to get just "prev". 回答1: git checkout - is shorthand for git checkout @{-1} (see here): You can use the @{-N} syntax to refer to the N-th last branch/commit checked out using "git checkout" operation. You may also specify - which is synonymous to @{-1} . You can pass

Create new branch based on current branch to work on a new feature

£可爱£侵袭症+ 提交于 2020-06-24 17:55:09
问题 How do I create a new branch in git to begin work on a new feature? I want the new branch to be a duplicate of the current branch (ie, the new branch's HEAD should be the same as the current HEAD). Question differentiation: Create a branch in Git from another branch seems related but is actually about why a branch is fast-forward merged. How do you create a remote Git branch? is about creating a new branch on a remote. 回答1: TL;DR: To create and start work on a new branch called FEATURE , you

Create new branch based on current branch to work on a new feature

谁说我不能喝 提交于 2020-06-24 17:51:21
问题 How do I create a new branch in git to begin work on a new feature? I want the new branch to be a duplicate of the current branch (ie, the new branch's HEAD should be the same as the current HEAD). Question differentiation: Create a branch in Git from another branch seems related but is actually about why a branch is fast-forward merged. How do you create a remote Git branch? is about creating a new branch on a remote. 回答1: TL;DR: To create and start work on a new branch called FEATURE , you

How can I switch to another branch in git?

纵然是瞬间 提交于 2020-06-23 20:32:27
问题 Which one of these lines is correct? git checkout 'another_branch' Or git checkout origin 'another_branch' Or git checkout origin/'another_branch' And what is the difference between these lines? 回答1: If another_branch already exists locally and you are not on this branch, then git checkout another_branch switches to the branch. If another_branch does not exist but origin/another_branch does, then git checkout another_branch is equivalent to git checkout -b another_branch origin/another_branch

How do I clone, fetch or sparse checkout a single directory or a list of directories from git repository?

流过昼夜 提交于 2020-02-15 06:42:04
问题 How do I clone, fetch or sparse checkout a single file or directory or a list of files or directories from a git repository avoiding downloading the entire history or at least keeping history download at minimum? For the benefit of people landing here, these are references to other similar questions: How do I clone a subdirectory only of a Git repository? How to sparsely checkout only one single file from a git repository? These similar questions were asked some 10 years ago and git evolved

Difference between checkout existing and checkout new branch in Sourcetree

老子叫甜甜 提交于 2020-01-23 18:20:33
问题 In sourcetree I would like to just check out to the remote develop branch so I can start a new feature branch in there. I'm currently in another feature branch in which I have committed and pushed all my changes. However when I right click on remote branch origin/develop I get this: For some reason I can find nowhere what is the difference here. I don't want to break the repo at my new job, so I'm super careful. In GitKraken you just checkout to remote and update your local develop branch if

How to do 'git checkout --theirs' for multiple files (or all unmerged files)

女生的网名这么多〃 提交于 2020-01-22 05:00:07
问题 Say I have this after attempting a merge and upon entering git status : # Unmerged paths: # (use "git add/rm <file>..." as appropriate to mark resolution) # # added by them: myfile1.xhtml # added by them: myfile2.xhtml # added by them: myfile3.xhtml ... and I know I want to do this for each of those files: git checkout --theirs myfile1.xhtml git add myfile1.xhtml ... but there are many of them. How might I do them as a batch? 回答1: The solution for my case ended up being to simply use a

git checkout remote branch shows extraneous files?

前提是你 提交于 2020-01-14 04:20:28
问题 master branch has these files and folders (simplified): C:\Local\TickZoom\Project>ls file.txt name.txt public public branch is tracking a vendor repository and has been subtree merged as public folder in master branch above. public has three folders only (simplified): C:\Local\TickZoom\Project>ls platform providers www When switching from public to master it behaves correctly. However, when switching from master to public, an odd thing happens. It has all the files and folders of both