T O P

Can I see all of my changes before I push them and open a PR?

Can I see all of my changes before I push them and open a PR?

joylongdivision

git diff target_branch..current_branch Where current_branch is the branch you will open the PR from (or HEAD) and target_branch is the branch you want to merge into. Note that since this is just regular git diff all the same format options or path arguments can also be applied. https://git-scm.com/docs/git-diff


aioeu

I would actually suggest doing the diff the other way around, i.e. one of: git diff target_branch current_branch git diff target_branch @ git diff target_branch depending on precisely what you want. It means the changes will be represented the correct way around. For instance, if you're adding lines you probably want them to be marked with `+`, not `-`. It also makes it a lot clearer how the three variants of this command are related to one another. (You can use `a..b` or `a...b` commit range notation in `git diff`, but it doesn't have the same meaning that it has in other Git commands. Probably best to avoid it.)


joylongdivision

You know, whenever I run that command I get the branch order wrong the first time every time, so of course I did the same here. You’re right, I have them backwards. Edited it, thanks for the callout.


SeerLite

I also used to get them wrong until I realized it's always `diff `. What confused me is that when you only give it one argument, git tries to be smart and decides the order automatically. Lately I've just been specifying both arguments everytime just to not mess it up :P


xf6jx5fq

Draft PR


BlueInt32

I have never used intelliJ's integration for git so I can't tell you how good it is. One sure thing though, is that to learn the basics of git, you will probably be better off using the CLI for quite some time before using some IDE's integration. Those tend to hide away important stuff about how git works and in the first days, you don't want that. I have seen several devs using only webstorm's git integration (they never used the CLI) and they had some weird misconceptions about the basic git workflow, basically making the whole team lose quite some time. If you want to go on the CLI path, one of the key things to configure on your git setup is the [difftool](https://git-scm.com/docs/git-difftool). It will behave just like `git diff`, but will pass the differences to a tool you chose. `git diff` is cool but it does not do a great job to compare several nested files in a project tree. I know this is not everybody's cup of tea, but I have been using beyond & compare for this for several years now; when I want to control big diffs and it never failed me. [Here is what it looks like](https://www.scootersoftware.com/features.php).


IntuitionaL

Yep I've started learning Git through CLI actually and it's still my go-to. However, I use Android Studio git integration sometimes for checking out branches and seeing what branch I'm on. I was curious whether Android Studio actually had a good visual interface for seeing diffs but I'll check it out using CLI first.


ntolbertu85

I used git bash on windows for the first few years. Now I sometimes use gitKraken on ubuntu, but find myself using it in parallel with the terminal, as there are some things that the terminal does better. On any gui that Ive used (especially IDE integrations) some features are either missing altogether or else buried away to a point that getting to them interrupts my workflow.


jftuga

From the command-line, try this: `git diff` or `git diff filename.java` To see a summary of what files have changed: `git status`


felipec

Easy: git log --patch master..mybranch


AnotherCableGuy

I always rebase with the target branch, push to remote and do a compare using the web interface before adding reviewers and open the pull request. If something is wrong during the compare phase, just add as many commits as necessary. Once I'm happy with the final result, just squash all commits and force push to remote.


thescientist13

If you want to see the diff in a more visual way, I made this little tool you can use to get a more “PR” like experience locally. https://github.com/thescientist13/git-explorer


morewordsfaster

As you're starting to explore diff and log, I highly recommend taking a look at forgit and diff-so-fancy that definitely make browsing changes more friendly in the CLI.


mmelikes

'git diff' is the simplest way but there are also nice tools like Github Desktop and other GUIs that give you a nice overview of your changes, comparison to branches and commits, and option to quickly take cool git actions. But IntelliJ IDEs also have a good enough integration for git afaik.


ntolbertu85

`git log` will give you an ordered list of your commits