Skip to content

Instantly share code, notes, and snippets.

@Eibwen
Created April 25, 2018 22:26
Show Gist options
  • Save Eibwen/7f5474c684e0226be5b2d7260fc041a7 to your computer and use it in GitHub Desktop.
Save Eibwen/7f5474c684e0226be5b2d7260fc041a7 to your computer and use it in GitHub Desktop.
Git quesiton
@echo off
:: Get into the repo
cd testrepo
:: Structure setup
mkdir build
:: Simulate src
echo Shit that was a mistake! > src\source.txt
git add src\source.txt
git commit -m "I fix codes!"
:: Simulate build (still on devel branch)
copy src\source.txt build\compiled.txt
echo EXPECT: compiled is new message (Stop now if want to test checkout/reset/whatever)
echo PROBLEM IS FROM THIS STATE, git checkout overwrites untracked files that are tracked in the switching to target branch
pause
:: Switch to release (TODO merge here????)
git checkout release
echo EXPECT: compiled didn't get reverted
pause
:: commit on this branch
git add build\compiled.txt
git commit -m "FIXED release!!!!"
echo EXPECT: FIXED release!!!!
gitk --all
pause
git checkout devel
@echo off
:: Setup from scratch
mkdir testrepo
cd testrepo
git init
echo Hello dudes > README.md
git add README.md
git commit -m "initial commit"
:: Setup branches
git branch devel
git branch release
git checkout devel
:: Add .gitignore
echo /build > .gitignore
git add .gitignore
git commit -m "Add git ignore"
gitk --all
:: pause
:: Structure setup
mkdir src
mkdir build
:: Simulate src
echo Omg bbq > src\source.txt
git add src\source.txt
git commit -m "I wrote codes!"
:: Simulate build (still on devel branch)
copy src\source.txt build\compiled.txt
:: Switch to release (TODO merge here????)
git checkout release
:: commit on this branch
git add build\compiled.txt
git commit -m "First release!!!!"
gitk --all
:: pause
git checkout devel

Want to have 2 branches in a repo, with 1 branch setup to generate files, but then have those generated files only committed to the other branch

So lets say the branches are devel and release

I want to run npm run build whilst on the devel branch It outputs to a folder /build/ which is ignored by .gitignore on the devel branch

Then I want it to switch to the release branch, which already has a /bulid/ folder And commit any changes under that folder to the release branch

@Eibwen
Copy link
Author

Eibwen commented Apr 25, 2018

Its seeming like git checkout release is not the command I want... But figuring out git documentation blah...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment