- Instructions
- Settings for SSH
- Initiate a repository
- Clone the repository with HTTPS
- Go to the repo folder directory
- See all changes in the repository
- Before you commit
- Now commit you file!
- Push commited files to a remote repository
- Create .gitignore
- Remove files
- Revert deleted files
- Branching
- See changes
- Pull requests
- Update changes in the remote repository to local
- Merge branches
- Update with changes in the master branch
- After the merge, delete the branch
- Log of all commits
- Undoing shit
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Set a name and password for the key files.
Look at your files:
ls
There will be 2 files:
- yourkeyame: your private key (don't share)
- yourkeyname.pub: you public key
Making sure that the git knows that key Ensure the ssh-agent is running
eval "$(ssh-agent -s)"
git init
Create an empty repository on github.
And then connect
git remote add origin https://github.com/ericyaang/git-instructions.git
Check the connection
git remote add origin https://github.com/ericyaang/git-instructions.git
Push!
git push origin master
git clone https://github.com/user-name/repo-name.git
cd repo-name
ls -la
This command will show you all the changes that have not been committed yet.
git status
If the file is untracked, this means that you need to add the file to git before anything else.
git add file
or use . to track all files.
git add .
git commit -m "what and why" -m "some description"
origin
is the location of the repository.
master
is the branch that we want to push.
git push origin master
Lazy push:
git push -u origin master
then just type use: git push
touch .gitignore
git rm file.txt
Remove only from repository
git rm --cached file.txt
git reset --hard HEAD
See what is there
git branch
Switch between branches
git checkout branch-name
Create a new one
git checkout -b name-of-the-branch
git diff name-of-the-branch
A request to have your code pulled in another branch
Create request pull to the master branch
git push origin branch-name
git pull
Remember to checkout
git diff master
git merge master
git diff master
git commit -am "updated with master"
git branch -d name-of-the-branch
git log
Staged
git reset name.py
Commits
git reset HEAD
Vorletzte commit
git reset HEAD~1
For multiple commits, check log and copy the hash of the commit and then
--hard
to remove all changes
git reset --hard c2119af9239eaf762e7e84a7a4859d42f8665660