我正在与一个团队合作,我们正在使用GitHub。
让我按如下所示设置两个远程存储库:
上游:这是整个团队的集中存储库。
来源:这是上游的分支存储库。
所有这些存储库都具有用于开发的分支'develop'。我在本地分支'develop'上工作,该分支将在以后推送至起源/开发。
以下是我在创建拉取请求之前发出的命令。请注意,我当时已签到本地'develop'。
package it.univaq.we.internshipTutor.model;
import ...
@Entity
@Table(name = "professor")
public class Professor {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Transient
private UUID uuid;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "department_id", nullable = false)
@NotNull(message = "this field is mandatory")
private Department department;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "professor")
private List<StudentInternship> studentInternships;
@Column(name = "first_name", nullable = false, length = 255)
@NotEmpty
private String firstName;
@Column(name = "last_name", nullable = false, length = 255)
@NotEmpty
private String lastName;
@Column(name = "email", nullable = false, length = 255)
@Email
@NotEmpty
private String email;
...getters and setters...
}
最后一个推送命令成功。然后,我创建了一个从 origin / develop 到 upstream / develop 的拉取请求。但是,在GitHub中,pull请求显示了同事的其他提交。这使得审阅者几乎无法审阅我所做的更改。
我的问题是:如何创建更清洁的拉取请求?
我的解决方案是,我不按以下方式调用package it.univaq.we.internshipTutor.model;
public class ProfessorInternshipCount {
private Professor professor;
private Integer count;
public ProfessorInternshipCount(Professor professor, int count) {
this.professor = professor;
this.count = count;
}
...getters and setters...
}
,而是按以下方式调用org.springframework.core.convert.ConverterNotFoundException:
No converter found capable of converting from type
[org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap]
to type
[it.univaq.we.internshipTutor.model.ProfessorInternshipCount]
...
:
$git commit
$git pull --rebase=preserve upstream develop
$git push
To https://github.com/lamhohs/some_repo.git
! [rejected] develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://github.com/lamhohs/some_repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git pull --rebase=preserve origin develop
$ git push
尽管如此,拉取请求还包含从 upstream / develop 到本地'develop'的合并提交。
答案 0 :(得分:0)
2个解决方案:
通过SHA执行代码检查。无论使用哪种系统,都必须支持某种SHA选择进行代码审查。类型:
gitk&
找到您的提交的SHA。将这些SHA上载到您的代码审查中,它将仅显示那些提交中的更改。
确保您的更改是最后的更改。这些步骤可以将您所有的提交都变成1次提交,这是分支上的最新提交。
git branch -m "mydevelop"
git pull
git checkout develop
git merge --squash mydevelop develop
git commit -m "my changes as one commit"
正如choroba所说,您不应在工作中使用同名的开发分支。您应该将其拉出,重命名,在重命名的分支上进行工作,然后在准备好与开发合并时,也就是将其合并回开发时。 如果您继续直接对developer分支进行更改,那么如果您对git不太了解,将来会遇到更多麻烦。