# Git section in porters handbook seems wrong



## neal (Apr 20, 2021)

I've been reading the git section in the porters handbook in order to make some new ports and things are not working as suggested.

I have added my new ports with 
	
	



```
git add
```
 and then when I try to do a pull as described in the handbook, I get the following:


```
git pull --rebase
error: cannot pull with rebase: Your index contains uncommitted changes.
error: please commit or stash them.
```

What's the correct workflow to add or change files in order to be able to create a diff?


----------



## SirDice (Apr 20, 2021)

It seems to be missing a commit step after you added your files.


----------



## zirias@ (Apr 20, 2021)

`git add` only stages changes for commit. For rebasing local commits on whatever is fetched, you need to commit them first with `git commit`.

But then, the simplest version is to just do nothing, `git diff` will then show the diffs from your working copy compared to the latest HEAD. If you want to undo the `git add` (IOW remove the files from the staging area), you can use `git restore --staged`.


----------



## neal (Apr 20, 2021)

What would be the point of committing the changes, as they will never be pushed anywhere. The real changes will be via the generated diff.

Even if I don't `git add` anything, the presence of changed files stops the `git pull --rebase` from happening.


----------



## SirDice (Apr 20, 2021)

How I would do it, is to create a new branch. Do the development in there, add and commit the changes. Then rebase with the main branch before creating a git patch file.


----------



## neal (Apr 21, 2021)

It seems that the command in the ports manual to create the diff needs to be changed to:
`git diff --cached . > ../`make -VPKGNAME`.diff`
This produces a diff of the changes staged for the next commit.

I think I'm going to have to read the whole git manual as it's way more complex than any of the other version control systems that I've used (CMS, CVS, SVN and Mercurial).


----------



## bobmc (Apr 21, 2021)

I also find it challenging.

It's not too complicated when you are managing your own work. If Git or Mercurial already existed when FreeBSD was created, then the Ports would probably have a simpler workflow.


----------

