branch

Git命令

半世苍凉 提交于 2019-11-28 16:24:01
Git主要流程 一、创建仓库 # 在当前目录初始化一个Git代码库 $ git init # 新建一个目录,将其初始化为Git代码库 $ git init [project-name] # 下载一个项目和它的整个代码历史 $ git clone [url] 二、配置 Git的配置文件为.gitconfig,它可以在用户的主目录下(全局配置),也可以在项目目录下(项目配置)。 # 显示当前的Git配置 $ git config --list # 编辑Git配置文件 $ git config -e [--global] # 设置提交代码时的用户信息(全局) $ git config --global user.name "[name]" $ git config --global user.email "[email address]" 三、代码提交 将代码提交到Git仓库的过程中,经历了以下区域:workspace(工作空间)->index(暂存区)->Repository(本地仓库)->Remote(远程仓库) 提交到暂存区 # 添加指定文件到暂存区 $ git add [file1] [file2] ... # 添加指定目录到暂存区,包括子目录 $ git add [dir] # 添加当前目录的所有文件到暂存区 $ git add . # 添加所有目录的中的已修改文件到暂存区 $

How to do a pull request in GitHub with only the latest commit in the master branch of my forked repository

谁说我不能喝 提交于 2019-11-28 16:22:45
I forked a repository on github. I made some changes and did a pull request. Now I made some other changes and want to do a new pull request, but on the preview screen before doing the pull request it shows the old commits too (the ones that were already accepted). How do I select only the latest commit in the master branch of my forked repository so that I can do a pull request with only that commit? This answer from a coworker fixed my problem: git checkout -b NEW_BRANCH_NAME LAST_COMMIT_NAME_BEFORE_THE_ONE_WANTED git cherry-pick COMMIT_NAME_WANTED git push origin NEW_BRANCH_NAME Then on

How can I start a clean branch with no ancestry, then commit files progressively?

大憨熊 提交于 2019-11-28 16:13:47
问题 I have a PHP framework versioned with GIT and I'm planning several (drastic) changes to its core. What I want to do is to start working on the new core in a new branch, but since this change might require some restructuring on the filesystem too, I'd like to start this new branch as cleanly as possible. I want the clean branch to include only with the core files. As I'm finishing my changes, I want to add the rest of the modules from the framework to the working directory one by one, but keep

Split a git branch into two branches?

不羁岁月 提交于 2019-11-28 16:12:41
I'm trying to help out a coworker who accidentally created one feature branch from another feature branch, rather than creating the second one from master. Here is essentially what we have now… Master ---A---B---C \ Foo E---F---F---H \ Bar J---K---L---M And here is what we'd like to have… Master ---A---B---C |\ Foo | E---F---F---H | Bar J---K---L---M One way I thought of would be to create FooV2 and BarV2 branches, and cherry-pick the individual commits into the appropriate V2 branches. But I'm curious, is there a better way to handle this situation? It looks to me like you could: git checkout

Push a commit in two branches with Git

流过昼夜 提交于 2019-11-28 16:03:47
how do I push a commit in two branches? I can't use "git push", because then it pushes to three branches, and i just want the commit in two of them.. Ive tried a "git merge HEAD --commit id from branch A--" in branch B, but then it takes everything from branch A and merges with branch B. I just want the last commit and not everything else merged with branch B. Anyone know what to do? Short answer You can apply already existing commit to another branch using cherry-pick command, and then push both branches using git push origin branchA branchB . Why pushing a commit in two branches might be

Push branches to Git

…衆ロ難τιáo~ 提交于 2019-11-28 15:57:39
问题 I have a local repository I'm working on and its remote is hosted on GitHub. I recently created a branch and started working on it, making several commits and now wish to push the branch to GitHub and be able to pull it to another cloned repository. What needs to be done to accomplish this? If this is not possible using GitHub, I'd be happy to know how to do it normally. 回答1: git push origin <local-branch-name>:<remote-branch-name> Substitute for <local-branch-name> and <remote-branch-name> .

Why is there a `remotes/origin/HEAD -> origin/master` entry in my `git branch -l -a` output?

拥有回忆 提交于 2019-11-28 15:38:53
I don't understand the second line in the output to git branch -l -a : remotes/origin/HEAD -> origin/master . git branch -l -a * master remotes/origin/HEAD -> origin/master remotes/origin/master Is that a leftover from another operation? Should I clean it up? And how would I do that? Usually I work with git on the cli, but on this local repository I experimented with TortoiseGit to find an easy git workflow for a friend. No, no need to clean up: it is the symbolic branch referenced by your remote repo. When you clone your repo, you will be by default on the branch referenced by remotes/origin

Git: copy all files in a directory from another branch

只谈情不闲聊 提交于 2019-11-28 15:32:54
How do I copy all files in a directory from another branch? I can list all of the files in that directory by doing git ls-tree master:dirname I can then copy all of the files individually by doing git checkout master -- dirname/filename However, using wildcards has so far been a total fail. This does nothing: git checkout master -- dirname/*.png Though I guess I can use a bash script to do that, there has to be an easier way, right? As you are not trying to move the files around in the tree, you should be able to just checkout the directory: git checkout master -- dirname test30 If there are

Take all my changes on the current branch and move them to a new branch in Git

帅比萌擦擦* 提交于 2019-11-28 15:28:46
问题 I started work on what I thought would be a minor bug fix on my master branch. However, it has spiraled out of control to the point where I wish I had created a separate branch to do the development in the first place. So right now what I'd like to do is: Create a new branch called (say) "edge" Move all the changed / untracked files on master to edge (such that master is unchanged from when I started the bug fix) Finish my work on edge, merge back into master How can I do this? 回答1: If you

Git pull into wrong branch

左心房为你撑大大i 提交于 2019-11-28 15:28:08
问题 Myself and one other developer had been merging and pushing our work to a non-master branch called toolwork. That way, we didn't impact the rest of the team. My topic branch was called DPM-93 and my git workflow was this. # do some work git checkout DPM-93 git commit -m "did some work" # catch up git checkout toolwork git pull origin toolwork # rebase my topic branch git checkout DPM-93 git rebase toolwork # merge and push my changes git checkout toolwork git merge --no-ff DPM-93 git push