s1eepercat
10/3/2019 - 2:17 PM

Git


GITHUB PAGES REFRESH:
git commit -m 'rebuild pages' --allow-empty
git push origin <branch-name>



git clone https://github.com/s1eepercat/clean-project
!NOW REMOVE GIT INIT!

--------------GIT VERSION CONTROL ----------------
echo "# cooking-app" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/s1eepercat/cooking-app.git
git push -u origin master



git init - Create an empty Git repository or reinitialize an existing one

git clone https://github.com/s1eepercat/background_generator.git

git status = shows if different from github files exist 

git add *filename* = adds files into queue to github commit
git . = adds all files
git commit -m "MESSAGE" = commiting changes to github

*IF WORKED IN TEAM, BEFORE PUSHING, SHOULD GO TO MASTER BRANCH AND PULL TO CHECK IF NO CONFLICTS*
git push = actually push to github

git push origin *brancename* = punpm sh to repo, origin means FORKED repo (copied)

git pull = pulls the latest from github

----

git branch = lists all the branches

git branch -d *name* = removes a branch

git branch -b *name* = creates a new branch

git checkout *name* = switch to a different branch

git checkout -b *name* = create and switch

git revert = removes last commit pushed to Github

----

PULL EVERY FILE FROM REPOSITORY AND OVERWRITE LOCAL CHANGES:

git fetch --all
git reset --hard origin/master

----

*IF MULTIPLE PEOPLE WORK ON DIFFERENT BRANCHES*
after commiting files to branch, go pull from master branch and do the following: 

git merge master (while git is in a different branch) = merges from master into it
might get conflict or not. if not, everything is good, if conflict - 
now files are changed and need to go review the code and fix mistakes, 
than you can push once again with git add ., git commit -m "fixing", git push
with


------------------------

You may have noticed something while watching the previous video...
Do you have to always fork the Open Source project every time master get's updated? 
Luckily for you, there is a easy way to always make sure your fork has the most 
up to date version of the original project. Here is how:

Type git remote -v and press Enter. You'll see the current configured 
remote repository for your fork.
    git remote -v
    origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)


Type git remote add upstream, and then paste the URL you would copy from 
the original repository if you were to do a git clone. Press Enter. 
It will look like this:
	git remote add upstream https://github.com/zero-to-mastery/PROJECT_NAME.git

To verify the new upstream repository you've specified for your fork, 
type git remote -v again. You should see the URL for your fork as origin, 
and the URL for the original repository as upstream.

    git remote -v
    origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
    upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
    upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)