Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The good git process to work alternatively at home and at office [duplicate]

Tags:

git

I'm working half time at home, half time at the office. Each task must be done into a dedicated, separated, branch, merged after peer review.

Our project is backed by Bitbucket, we use Jira and Jenkins too.

I use only one remote repository and two local repositories.

I have a recurrent problem: some conflicts occurs between me (@home) and me (@agency)...

here is my process:

Monday, at the office, in a branch named "JamesBond007" derived from master :

git add --all
git commit [--amend]
git push [-f] origin remote/JamesBond007

Tuesday, at home:

git checkout master
git pull
git checkout JamesBond007
git pull --rebase origin master

Wednesday, at the office:

git checkout master
git pull
git checkout JamesBond007
git pull --rebase origin master   **<-- conflict: git mergetool command needed!!!**

My workaround:

rm -fr repo
git clone ssh:repos-url

Where is my mistakes, how can I push/pull code from two local repos to/from the server without conflict?

like image 748
Aubin Avatar asked Jan 11 '19 19:01

Aubin


People also ask

How do I duplicate a git repository?

Mirroring a repository that contains Git Large File Storage objects. Open Terminal . Create a bare clone of the repository. Replace the example username with the name of the person or organization who owns the repository, and replace the example repository name with the name of the repository you'd like to duplicate.

Which best describes the typical basic git workflow?

The most popular Git workflow is the usage of pull requests. In this workflow a developer uses a server side functionality to request that commits from a branch (from the same or another repository) are integrated into another branch (in the same or another repository).


1 Answers

I have a very similar setup and never have merge conflicts: I essentially do what you do, but I never use rebase in any fashion, until possibly at the very end, as part of merging to master.

Concretely:

  • I commit and push frequently while I'm working, using the origin as a backup tool.
  • I can switch easily to another computer by just doing a default fast-forward pull/fetch on it, and then getting to work there.
  • Finally, when the code has been reviewed in the PR, I perform some kind of merge or rebase or squash/merge depending on the project's style.

I know that this is not the preferred "expert" way to work, but it has two awesome benefits:

  1. I switch between multiple development computers (desktop here, laptop or two there...) without any thought at all. Just a git pull and I'm off...
  2. I never have conflicts.
like image 72
Dogweather Avatar answered Oct 22 '22 18:10

Dogweather