How to Git with PcmHacks in Visual Studio

They go by many names, P01, P59, VPW, '0411 etc. Also covering E38 and newer here.
Post Reply
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

How to Git with PcmHacks in Visual Studio

Post by Gampy »

Updated: 2022-02-07

Many many people have difficulties getting involved in an existing Github project.

The most common mistake is cloning the repository they want to contribute to, DO NOT DO THAT!
First create a Fork of that repository, then clone that fork ...

The second biggest mistake is not creating a private branch, thus making changes to the 'Master' branch (In PcmHacks case it's called 'develop' ... :?), DO NOT DO THAT!
Create your own branch, make your changes in that branch, commit them to that branch, then push that branch to your fork, then create a pull request from your fork.

The next mistake is miss understanding the Origin / Upstream naming, I must admit it is confusing, but not if you look at it right.
Your fork is Origin, it's the origin of your clone ... The repository that you forked, is Upstream of your fork!
Local clone -> Origin (Your fork) -> Upstream (The repository you forked).

You pull from upstream, you push to origin.

Simply stated steps ...
Remote,
. . Fork a repository
Local,
. . Clone that fork local
. . Create the canonical name 'upstream' (it points to the repository you forked, origin points to your fork and is automatically created)
. . Create a local branch
. . . . Make your modifications
. . . . Stage the changes
. . . . Commit the changes
. . . . Push that branch to your fork
Remote,
. . Create a pull request from your fork ...
------
After it's accepted (if it is :roll:) ...
Local,
. . Pull the upstream repository to update the local clone
. . Push the local clone to update the fork
. . Delete your Feature branch
Remote,
. . Delete your Feature branch
I am NOT A DOCUMENT WRITER, I do the best I can!
I abhor the Git GUI in Visual Studio ... I prefer using Git via CLI.

However I whipped up this in hopes it would help others Git involved ... Enjoy!
2022-01-11
GitWithPcmHacks-v2.pdf
(899.17 KiB) Downloaded 11 times
2022-01-15
GitWithPcmHacks-v2.1.pdf
(728.88 KiB) Downloaded 138 times
2022-02-07
FMI See,
Visual Studio Git GUI pain relief, click here: Git CLI in Visual Studio!
Rebasing from the Visual Studio Git GUI, click here: Confused Rebase in Visual Studio Git GUI!
I will keep this location Updated.

Comments, Improvements, Corrections, Critiques welcome ...

As always, I am ALWAYS willing to help anyone ... To the point of sticking my nose in where it's not wanted sometimes!
But that's me, don't like it (or me), go suck an egg ... :)
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: How to Git with PcmHacks in Visual Studio

Post by Tazzi »

Thankyou for this. Personally am terrible with understanding how the whole request pull and merging works. Possibly a tutorial on that would help!

I just always make a new brank, clone the master into it and then make the edits from there. After that.. I havent been game enough to merge after a fuck up near the beginning of the project haha
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: How to Git with PcmHacks in Visual Studio

Post by Gampy »

Not sure I understand the question, it's a bit jumbled, it looks like you want to do PR merges into your own repository, thankfully GitHub has made that easier by including that functionally in GitHub and it's point and click now.

NOTICE! This comment is for owners of a repository, not for contributors to forked repositories!

Previously it would have been (from the CLI),
checkout master
pull origin master
checkout -b feature
pull origin pull/PR#/head
rebase master
checkout master
merge feature
push origin master
and is still my preferred method ... It's cleaner!

And of course you'll want to wipe when done,
branch -d feature
no brown stripes left behind!

One thing I do HIGHLY recommend for those wanting to smooth out their Gitmo, is to have multiple (at least two) GitHub accounts, that way you have your own full circle LAB to play in!

-Enjoy
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: How to Git with PcmHacks in Visual Studio

Post by Gampy »

New version up.

Mostly a formatting change, I finally got around to figuring out how to make the only suggestion made, moving the text along side the images.
You know who you are, Thank you!

There are a couple new tips as well, nothing important.

-Enjoy
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
jlvaldez
Posts: 155
Joined: Mon Feb 11, 2019 12:48 pm
cars: '01 - Corvette Z06
'20 - Sierra Denali
'03 - Volvo S80 T6
'16 - Accord V6
Location: DFW, Texas

Re: How to Git with PcmHacks in Visual Studio

Post by jlvaldez »

Thanks for the info. I do a lot of programming for personal projects only and have developed terrible habits with git. I'll be honest that s lot of what scares me about contributing is that I don't understand how git work flow works in a group
ironduke
Posts: 579
Joined: Thu Feb 13, 2020 11:32 pm
cars: Mainly GM trucks, a Cruze and an Equinox for dailys..

Re: How to Git with PcmHacks in Visual Studio

Post by ironduke »

jlvaldez wrote:Thanks for the info. I do a lot of programming for personal projects only and have developed terrible habits with git. I'll be honest that s lot of what scares me about contributing is that I don't understand how git work flow works in a group
X2, same here.. Thanks for writing this up.. I will give it a go again at some point, now with better understanding..
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: How to Git with PcmHacks in Visual Studio

Post by Gampy »

Updated: 2022-02-07

Thought I would drop this out there ...

For those of you that like to work at a Console, Git in Visual Studio has a CLI with some limitations ... I don't think MS meant for it's use this way!

However it does work awesome and for most things it is far superior to the GUI ... Also, there are some things you just cannot accomplish in the GUI, that you can accomplish using the CLI.

First you need to find where MS hid it, the location depends on way to many things to get into here, so, it's generally located somewhere along the lines of,

Code: Select all

C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin
You also need the '*\Git\usr\bin' path,

Code: Select all

C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\usr\bin
What you're looking for is,

Code: Select all

*\Git\mingw32\bin
And

Code: Select all

*\Git\usr\bin
Copy save the locations someplace ... I made a batch (cmd) file as shown below.

Then open a command prompt and add the found locations to the path, AS AN EXAMPLE you would type the following at the prompt,

Code: Select all

set path=%path%;C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin;C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\usr\bin
If you must use Powershell,

Code: Select all

$env:Path += ';C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin;C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\usr\bin'
Or simplify it by creating a batch (cmd) file that you can PIN to your Start Menu for easy access by following the below example GitCLI.cmd,

Code: Select all

@echo off
set path=%path%;C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin;C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\usr\bin
chdir %userprofile%\Source\Repos
start %windir%\system32\cmd.exe /k
If you must use Powershell, an example GitCLI.cmd,

Code: Select all

@echo off
set path=%path%;C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin;C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\usr\bin
chdir %userprofile%\Source\Repos
start Powershell
There probably is a better way, ATM I do not know it!

YOU MUST fix the paths in the above EXAMPLES, according to your system ... There are 3 paths that need to be fixed, 2 in the set path statement, 1 in the chdir statement that changes directory to where ever your projects are.

TIP: There is a %userprofille%\.gitconfig that is the Global git config file, this is where one would put things like aliases or your Name and Email.
For example I have an alias 'logn' that is used as 'git logn X' that displays the last X lines of the log in a pretty format like the following where X=10,

Code: Select all

d0e2e9d - 2022-01-16, NSFW : Merge pull request #242 from joukoy/CmdlineParserV2
6a10de8 - 2022-01-14, NSFW : Merge pull request #243 from LegacyNsfw/antus/avt-838
fcdbbea - 2022-01-14, Ylikulju Jouko : Cmdline Parameters v3
3dd250a - 2022-01-13, NSFW : Merge pull request #238 from Gampyg28/d_NoDeviceFound
9740558 - 2022-01-13, Jouko Y : Cmdline Parameters
f3a9b43 - 2022-01-04, NSFW : Merge branch 'develop' of https://github.com/LegacyNsfw/PcmHacks into develop
b1e02dc - 2022-01-04, NSFW : Added menu item to test a file's checksums.
6e38bb0 - 2022-01-04, Anthony Symons : no explicit firmware request on 842/852
094246c - 2022-01-04, Anthony Symons : document interface RS232 speeds
6c6f2d9 - 2022-01-04, Anthony Symons : Initial support for AVT-838 device
There is also a local (to the project repository) .gitconfig that overrides the global .gitconfig, so if you have multiple Github accounts, you can change them according to the specific project repository.

One thing you will want to add to your global .gitconfig is a pager program like,

Code: Select all

pager = more.com    
Add to the '[core]' section of '%userprofille%\.gitconfig'.

Hopefully this is useful to someone ...

Got questions, ask!

-Enjoy
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
jlvaldez
Posts: 155
Joined: Mon Feb 11, 2019 12:48 pm
cars: '01 - Corvette Z06
'20 - Sierra Denali
'03 - Volvo S80 T6
'16 - Accord V6
Location: DFW, Texas

Re: How to Git with PcmHacks in Visual Studio

Post by jlvaldez »

Ever use VSCode? As I don't do any .net development, never had a need to spring for VS.

I've noticed that the "terminal" in vs code on windows is just a powershell (which I'm not super familiar with, more of a linux man, myself)

Running git in this terminal just errors out
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: How to Git with PcmHacks in Visual Studio

Post by Gampy »

jlvaldez wrote:Ever use VSCode?
No.
jlvaldez wrote:never had a need to spring for VS.
VS has a Community Edition that is free, it's all I use.
jlvaldez wrote:I've noticed that the "terminal" in vs code on windows is just a powershell (which I'm not super familiar with, more of a linux man, myself)
Must be using Windows 10 or greater ... Yea, MS hides the Command prompt in favor of Powerhell.
I change all my systems back to the Command Prompt ... Powershell is way to sluggish for me!

Personally I prefer Unix.
jlvaldez wrote:Running git in this terminal just errors out
I do not believe it will work in Powershell, wouldn't waste my time trying! ;)

[edit]
Ok, I had to try ... It does work in Powershell, how you set the path in Powershell is different!
See: Here

Oh, and BTW, those that prefer Unix/Linux CLI, you can run the 'sh' command and be in the msys (puke) shell ... After the above setup is accomplished of course!
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: How to Git with PcmHacks in Visual Studio

Post by Gampy »

Something that I find extremely confusing and annoying in Visual Studio Git GUI ...

Rebasing ... It's backwards IMO!

Think of Rebasing like lifting your house (your Feature) and replacing the foundation (master) with a new one, then setting your house back down on the new foundation (updated master).
More technically, your feature is recorded, your Feature branch is updated, your feature is replayed on your Feature branch.

Rebasing is used for many reasons, the most important one is this scenario ...

You've created a feature branch based on master, you're working on it, it takes time, in the meantime master gets updated ...
Now your feature is no longer based on master (master head, specifically), it's based on a previous point in masters life (history)!
That's ok, you can continue developing your Feature just like normal all the way through to the end, the changes to master will be in master when your Feature gets approved and merged.

However, if you need (or want) the updates to master in your Feature now so you can finish your Feature, then you would need to Rebase your Feature with the updated master.

So, save everything, stage your changes, commit your changes (I'll not get into stashing).

Then to Rebase using the CLI it's simply done,
git checkout Feature
git rebase master
Spelled out, that is,
'checkout Feature' makes the Feature branch active ...
'rebase master' lifts up your Feature, pulls out the old master, replaces it with the new master and sets your Feature back down.

If there are no conflicts or other issues, it's done ... Your Feature is now based on the new master (master head) and you can continue developing it.

In VS Git GUI it is,
Select: Home
Select: Branches
Select: Rebase (the Link)
The two text boxes are,
. . Rebase from the current branch:
. . Onto branch:

Rebase from the current branch is determined by the checked out (active) branch.
Onto branch is a drop down list of available branches.

For a proper rebase, that is to update your Feature with master, you would do this,
. . Rebase from the current branch: Feature
. . Onto branch: master
EVEN THOUGH THAT SEEMS BACKWARDS according to the wording, it is correct!
That is how it has to be done for a Proper Rebase as outlined by Git documentation to Rebase your Feature with master ... Exactly like the CLI example above.

IF YOU DO,
. . Rebase from the current branch: master
. . Onto branch: Feature
As wording indicates YOU WILL REBASE YOUR MASTER BRANCH with your Feature branch, now your unfinished Feature is in master ... Not what you wanted!
Exactly what all the warnings and fear of rebasing comes from, one should never rebase a branch that has been shared.

It is perfectly fine to share a rebased branch, but not rebase a branch that is shared!
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
Post Reply