-
Notifications
You must be signed in to change notification settings - Fork 0
Git
move back one directory
$ cd ..
check status
$ git status
to add updated files
$ git add <file_path>
to undo git add and remove file from staging
$ git reset <file_path>
to save changes and add a comment
$ git commit -m "<first commit>"
To show file the differences of files not yet staged
$ git diff
To show differences between staged files and the last file version
$ git diff --staged
to check the differences between branches
$ git diff <branch_name> <other_branch_name>
to see the history of activity/ git commands on that branch
$ history
to see the last 10 commands
$ history 10
Update master branch (NOTE: git pull will add changes from other workspaces to yours, fetch will only see the changes but not apply)
$ git checkout master
$ git fetch origin -p
$ git reset --hard origin/master
$ git log
NOTE:
$ git fetch origin
can be executed on any branch
to create a new repo
$ git init <project_name>
to download an existing repo with it's version history
$ git clone <URL>
create new branch
$ git checkout -b <local_branch_name>
delete branch
$ git branch -d <local_branch_name>
display full list of git branches
$ git branch -a
to check current branch
$ git branch
Push local branch
$ git push origin <local_branch_name>
view the history
$ git log
Switch branches
$ git checkout <local_branch_name>
Remove file from staging
$ git rm <file_name>
$ git rm -r --cached node_modules/
Setting up Drupal environment in AWS
creating a new remote repository
create a new repo in the git UI, don't click add readme.md
In the terminal type mkdir <name> in the Sites directory ....
find …or push an existing repository from the command line in gitHub and paste the whole line into your directory
the run git push -u origin master
run
git remote rm origin
the run
git remote add myorigin git@github.com:myname/oldrep.git (find this on gitHub under …or create a new repository on the command line)
This command - I must read up on more !!
chmod 777 - this helped to resolve an error i had with not being able to pull file to master (i was 113 commits behind) this is the error msg error: Your local changes to the following files would be overwritten by merge: ``Please move or remove them before you merge
includes, remote origin, git url
environments / branches
- master
- release
- develop
- hot fix (the only time you can push directly to master) -feature
ERROR: git@github.com: Permission denied (publickey).
after running git push -u origin master I got this error :
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
the problem was that the SSH key on my personal wasn't added to my gitHub account.
so I needed to open a shell in the terminal, run cat ~/.ssh/id_rsa.pub or cat ~/.ssh/id_dsa.pub to access the SSH key
then copy the key ssh xvghsjchdkcdkchkc
open gitHub, go to settings and select SSH and GPG Keys, then select New SSH Key