Beginning a new project
- git init
- git add -A
- git commit -m "My Message"
- Create GitHub repo
- Make sure ssh is checked and copy commands from GitHub to add remote repo
to local project
- mkdir my-directory-name
- cd my-directory-name
- touch my-filename
- git init
- git add -A
- git commit -m "My Message"
- Create GitHub repo
- Make sure ssh is checked and copy commands from GitHub to add remote repo
to local project
- Fork project
- Choose only main branch or additional topic branches to be forked
- Copy ssh url from my repo
- Navigate in the command line to where directory will be added
- git clone ssh url from my repo
- cd my-project-name
- cd my-directory-name
- touch my-filename
- git init
- git add -A
- git commit -m "My Message"
- Create GitHub repo
- Make sure ssh is checked and copy commands from GitHub to add remote repo
to local project
Existing projects
- git add -A
- git commit -m "My Message"
- git push origin my-branch-name
- Add and commit all changes before switching branches
- git add -A
- git commit -m "My Message"
- git checkout -b my-topic-branch-name
- Add and commit all changes before switching branches
- git add -A
- git commit -m "My Message"
- git checkout main
- git merge my-topic-branch-name -m "My Message"
Working with a team
- Fork project
- Choose only main branch or additional topic branches to be forked
- Copy ssh url from my repo
- Navigate in the command line to where directory will be added
- git clone ssh url from my repo
- cd my-project-name
- Create a topic branch
- git checkout -b my-topic-branch-name
- Work on the topic branch
- git add -A
- git commit -m "My Message"
- Merge work into main branch
- git checkout main
- git merge my-topic-branch-name -m "My Message"
- Connect to the upstream repo
- git remote add upstream ssh url from upstream repo
- Fetch from upsteam branch
- Checkout main branch
- Merge upstream main branch into local main branch
- Checkout topic branch
- git checkout my-topic-branch
- Merge main branch into topic branch
- git merge main -m "My Message"
- git fetch upstream
- git checkout main
- git merge upstream/main
- git checkout my-topic-branch
- git merge main -m "My Message"
- Work on the topic branch
- git add -A
- git commit -m "My Message"
- Merge work into main branch
- git checkout main
- git merge my-topic-branch-name -m "My Message"
- All code has been added, committed, and merged into the main branch
- Push main branch to GitHub remote repo
- Issue pull request
- Click the "Pull Request" button
- Click the "Create Pull Request" button
- Click the "New Pull Request" button
- Choose which branch you want to compare
- Check the git diff to be sure the changes are what you want
- Click the "Create Pull Request" button
Troubleshooting
- What directory am I in?
- Have my changes been added and committed?
- What remote repos have been added to my directory?
- Read the error message
- Check for a typo
- Google the error message
- Be very careful if the command is to remove files or folders. Something
removed in the command line is
gone-gone! 😰
- Resolve merge conflicts in the text editor
- Remove all conflict markers
- git add -A
- git commit -m "My Message"
Resources