Git workflow - mikec964/chelmbigstock GitHub Wiki

Make sure you have the latest from Github

git pull origin master

Work locally

Make some changes to your files.

git add .  # add files to staging area
git commit -m <message>

To see the changes within the files that have changed but not been added or committed. git diff <file>

Undo

Git docs

If you don't like like the staged file, use:

git reset HEAD <file>

If you want to revert a file, use:

git checkout -- <file>

If you want to add or change a file after a commit, that should have been part of the commit:

git commit -m 'first try'

# edit files

git commit --amend

Working with Remotes

Git-scm Working with Remotes

See the short name for the remote url. This is probably 'origin'.

git remote

To pull code from remote:

git fetch [remote-name]

To push code back to the remote:

`git push [remote-name] [branch-name]

Q&A From Jay

  1. How can I review the changes between the remote and my code?

git diff origin/master

If you want to diff with a branch then

git branch -a <<<< lists all the branches

git branch < a branch from above output>

  1. How can I review the changes between my branch and my local master?

git diff master <<< I think this is default. You need to specifically give remote branch name to compare with remote.

  1. Can I merge the remote master into my branch, make some changes, then push it back to the remote master?

This is the normal process right?

Assume you are on your local working branch.

First you switch to master - git checkout master Pull updates from remote - git pull Merge your branch - git merge

then add, commit and push to remote.

⚠️ **GitHub.com Fallback** ⚠️