-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Git Basics | ||
|
||
## Set up your information | ||
``` | ||
git config --global user.name "John Doe" | ||
git config --global user.email "[email protected]" | ||
``` | ||
|
||
|
||
## Clone a repository | ||
``` | ||
git clone https://github.com/twin-bridges/pynet-ons | ||
``` | ||
|
||
|
||
## Add file to a repository | ||
``` | ||
git add my_file.py | ||
git commit -m "Adding my_file.py" | ||
``` | ||
|
||
|
||
## Remove a file/directory | ||
``` | ||
git rm ex1_strings.py | ||
git rm -r <directory> | ||
git commit -m "Removin ex1_strings.py | ||
``` | ||
|
||
|
||
## View status of repository and pending changes | ||
``` | ||
git status | ||
git diff | ||
git diff <file_name> | ||
``` | ||
|
||
|
||
## Push changes to remote repository | ||
``` | ||
git push origin main | ||
where 'origin' is defined in 'git remote -v' | ||
where 'main' branch is the src branch; dest branch is same as src branch | ||
``` | ||
|
||
|
||
## Pull changes from remote repository | ||
``` | ||
git pull origin main | ||
where 'origin' is defined in 'git remote -v' | ||
where 'main' branch is the src branch; dest branch is same as src branch | ||
``` | ||
|
||
|
||
## Branches | ||
``` | ||
git branch # Look at branches | ||
git branch dev # Create a 'dev' branch | ||
git checkout dev # Switch to 'dev' branch | ||
git checkout main # Switch back to 'main' branch | ||
git push origin dev # Push changes up to GitHub for 'dev' branch jj | ||
git merge dev # merge 'dev' into main (switch to 'main' branch first) | ||
git branch -d dev # delete this branch | ||
git branch -vv # To see the remote branch that it is tracking | ||
git branch -u origin/develop # Set current branch to track origin/develop (must exist) | ||
``` | ||
|
||
|
||
## Misc | ||
``` | ||
git log # View the commit log | ||
git log -p -1 # Show the changes in the last commit | ||
git stash # Temporarily save uncommitted changes | ||
git stash pop # Remove changes from stash and reapply to repository | ||
``` | ||
|