branch

Is there a way to make a local branch immutable?

浪尽此生 提交于 2019-12-05 13:41:20
I'm extremely stupid and sometimes I merge a "feature branch" in the wrong master branch as opposed to the develop branch and that of course leads to pain and suffering. Since it's the second time already that this has been happening, I wonder if there's a way for me to make a branch immutable locally. I've already tried with this pre-commit hook to prevent me from directly making commits on said branch, but this is not stopping merges as in: git checkout master git merge wip Is there a way to prevent all possible changes to a local branch? If not, is it at least possible to prevent changes

Git new file appears in all branches

半世苍凉 提交于 2019-12-05 13:23:06
I thought a file created on one branch will not appear in any other branches until I merge or rebase the branch? Example: I have two branches: master new_contact_page I checkout the new_contact_page branch. $ git checkout new_contact_page Then I create a new file. $ vi contact_page.html Without doing any Git commands, I switch back to my Master branch. $ git checkout master Then I see that this contact_page.html file is also in my Master branch. $ ls (contact_page.html shows up in the list!) Shouldn't the file only exist in new_contact_page branch? Git will never touch any files that aren't

git: How to create a branch of my current work, but stay on my original branch

浪尽此生 提交于 2019-12-05 13:15:10
I'm on a branch (let's say master), and I have some changes in my working dir. I get stuff working, but needing a lot of cleanup - so I'd like to save my current working dir to a branch just in case I need to go back to it. I'll definitely be deleting the branch later. In addition, I want to continue working on master EXACTLY where I was. Right now I do: # Save to topic branch git checkout -b working-stuff git commit -a -m "work in progress" # go back to master and continue with the state is was in before git checkout master git checkout -- . git reset Later on, I'll delete the topic branch.

Commit select changes to another branch then resume work on current branch?

时光毁灭记忆、已成空白 提交于 2019-12-05 12:18:33
问题 This happens often in my work flow: I'm working on a feature in a separate branch, and while doing this I'll come across small things that need fixing but are from higher up in the framework or site layout for example. I want to switch back to the main develop branch and commit changes from select files there, then go back to a feature branch, and rebase so that I can continue there with the unrelated tweaks/bugfixes out of the way. I'm using git stash and git stash pop to do this, but I'm

How do I safely delete a remote git branch?

微笑、不失礼 提交于 2019-12-05 11:45:55
问题 To delete a local branch in git I use git branch -d , but how do I safely remove a remote branch? I would like to delete it only when the remote branch is merged to my current branch . 回答1: The answer is partly covered here: How can I know in git if a branch has been already merged into master? While that post copes with local branches, you could find remote branches that are merged or not using git branch -r --merged to detect all remote branches that are already merged into the current git

Why would my local changes in Git be overwritten by checkout in this circumstance?

末鹿安然 提交于 2019-12-05 11:44:58
Say I have a branch A, and from that I branch B. I make a bunch of changes on A, then checkout B and do a git pull . Now I make a change on B but realize that it should've been in A. If I now try to git checkout A , I get "Your local changes to the following files would be overwritten by checkout" to the file I touched. Why would my change be overwritten if I just did a git pull in B and haven't touched that file in A since? The reason you get that message is that the underlying file (before your uncommitted modifications) is different between branch A and branch B. If the files were the same,

How to set tracking on an existing repo to a remote repo with ngit (or jgit)?

可紊 提交于 2019-12-05 10:34:41
I am working on a gui based helper utility that will: Init a local repo, Init (bare) a remote repo Add .gitignore based on a project type Commit all the files locally Add a remote repo to the local config Push master to the remote repo Create a develop branch and push it to master All this is done without git installed by using ngit (.NET port of jgit). But I can't figure out how to setup tracking to track master to origin/master and develop to origin/develop using just ngit . I can do it easily with git branch --set-upstream master origin/master However, I was hoping to avoid the dependency

理解git 中的HEAD指针&branch指针

女生的网名这么多〃 提交于 2019-12-05 09:05:57
理解git 中的HEAD指针&branch指针 Yooye 关注 2019.02.28 10:44:32字数 492阅读 668 HEAD指针 使用 git checkout 来移动HEAD指针,移动的对象可以是分支指针也可以是快照。 HEAD指针可以指向快照也可以指向branch。当指向branch时提交后会和branch指针一起向后移动,当不指向branch提交时时则会在一个detached状态。 分支(branch)指针 使用 git branch -f 来移动分支指针,移动的对象只能是快照。当且仅当HEAD指针指向分支指针的时候,提交才会有效。 实例 1.HEAD指针默认指向当前的分支指针,用星号表示,如master* master 2.移动HEAD指针, git checkout C1 这个时候HEAD指针指向的是快照,这个时候指针的状态称之为游离状态,detached。 这里写图片描述 3.HEAD指针在游离状态下提交, git commit 游离状态下提交的commit,没有分支指针指向。可以在游离状态下的快照新建分支或强制移动已存在的分支 这里写图片描述 4.移动HEAD指针,让他指向master分支指针 git checkout master 这里写图片描述 5.在master分支指针上提交 git commit 这个是正常的提交,和游离状态下的提交是不一样的

【前端开发环境】前端使用GIT管理代码仓库需要掌握的几个必备技巧和知识点总结

ぐ巨炮叔叔 提交于 2019-12-05 09:02:00
1. Git的三种状态 已提交 committed 已暂存 staged 已修改 modified 2. Git的三个区域 Git仓库 是 Git 用来保存项目的元数据和对象数据库的地方。 这是 Git 中最重要的部分,从其它计算机克隆仓库时,拷贝的就是这里的数据。 暂存区域 暂存区域是一个文件,保存了下次将提交的文件列表信息,一般在 Git 仓库目录中。 有时候也被称作`‘索引’',不过一般说法还是叫暂存区域。 工作目录 工作目录是对项目的某个版本独立提取出来的内容。 这些从 Git 仓库的压缩数据库中提取出来的文件,放在磁盘上供你使用或修改。 3. 基本的 Git 工作流程 在工作目录修改文件 暂存文件,将文件的快照放入暂存区 提交更新,找到暂存去文件,将快照永久性存储到 Git 仓库目录。 3.1 用户信息 [!NOTE] 当安装完 Git 应该做的第一件事就是设置你的用户名称与邮件地址。 这样做很重要,因为每一个 Git 的提交都会使用这些信息,并且它会写入到你的每一次提交中,不可更改。 git config --global user.name "huyaocode" git config --global user.email johndoe@example.com 3.2 加入暂存区 git add 文件名或路径 3.3 忽略文件 创建一个 .gitignore 文件

List remote branches in Mercurial

孤者浪人 提交于 2019-12-05 08:44:08
问题 Is there a way to list remote branches in Mercurial like there in Git? git branch -r I want to list the branches on a remote machine (e.g. Bitbucket), so using: hg branches -R `hg showconfig paths.default` --color false fails with abort: repository not local 回答1: No, it is not possible to list branches of a remote repository without cloning it to local. If there is SSH access to the machine having the remote repository, then Mercurial could be used directly: ssh server hg -R path/to/repo