cd ~/Documents/git-repositories/
- We need to grab the entire repository, selecting the branch needed and the local location that should be used (HTTPS):
git clone -b <branch-name> https://github.com/blue-ice/<repo-name>.git ~/Documents/git-repositories/<repo-name>
- YOU MUST
cd <repo-name>
cd ~/Documents/git-repositories/<repo-name>
- Does
git remote -v
match the fetch and push links that should be in use?- If not, then
git remote set-url origin [email protected]:blue-ice/<repo-name>.git
- If not, then
- Does
git rev-parse --abbrev-ref HEAD
match the branch name that should be in use?- If not, then
git checkout <branch-name>
- If not, then
- Now match everything up with
git pull
git add -A
git commit -m "<commit-message>"
git push
git reset
git reset --soft 'HEAD^'
- Re-
add
files - Re-
commit
files git push
- Do not change branches from the one that made the bad commit.
git reset HEAD^ --hard
git push origin -f
git commit --amend
git push --force
git fetch --dry-run
git pull
git checkout <commit-hash> <file-path>
- Checkout the branch that needs to be reset.
git fetch origin
git reset --hard origin/<branch-name>
- Change repo name on GitHub
- Change local repo folder name:
mv ~/Documents/git-repositories/<old-repo-name> ~/Documents/git-repositories/<new-repo-name>
- Change local pull and push destination
git remote set-url origin [email protected]:blue-ice/<new-repo-name>.git
- Check to see if the output of
git remote -v
is the correct address.
NOTE: Does not work behind firewall.
git remote set-url origin [email protected]:blue-ice/repo-name.git
git remote set-url origin https://github.com/blue-ice/repo-name.git
- (
git config --global credential.helper cache
)
- This will change the time that Git waits to ask you again for your username and password.
git config credential.helper 'cache --timeout=<time-in-seconds-to-keep-credentials>'
git checkout -b <new-branch-name>
git add ...
git push --set-upstream origin <new-branch-name>
- Ensure that the branch to be renamed is not the "default" branch (see repo settings on GitHub). If the branch to be renamed is the "default" branch, then just switch the default branch temporarily.
- Check out of the branch to be renamed locally.
- Locally, run
git branch -m <old-branch-name> <new-branch-name>
git push origin :<old-branch-name>
git push origin <new-branch-name>
git checkout <into-branch>
git merge <from-branch> --no-ff
git push
- Check out of branch and make sure it is not the default (found in github repo settings)
git branch -D <branch-name>
(local deletion)git push origin --delete <branch-name>
(remote deletion)
git log --pretty=oneline
- (
git add ...
) git diff --cached
- (
git commit ...
)
git branch --list
- The current branch will be marked with an asterisk and/or marked in green.
git tag
- Note: asterisks can be used as wildcards.
git tag -l '<tag-name>'
- see http://git-scm.com/book/en/Git-Basics-Tagging for now
- Commit and push all untracked changes.
- Remove everything:
git rm -r --cached .
- Now add everything again (.gitignore is in effect):
git add -A .
git commit ...
(Sample message: ".gitignored files removed from repo.")
- Create a file named
.gitignore
inside the root repository folder. - Put the rule
!*
inside the file.
see Forking a Repo
- Click the "Fork" button online on the project to you want to fork.
cd ~/Documents/git-repositories/
- We need to grab the entire repository, selecting the branch needed and the local location that should be used:
git clone -b <branch-name> https://github.com/blue-ice/<repo-name>.git ~/Documents/git-repositories/<repo-name>
cd <repo-name>
- Add a new upstream:
git remote add upstream https://github.com/<forked-user>/<forked-repo-name>.git
git push -u origin master
git add ...
- ```git commit ...````
git push -u origin master
- Make sure that an upstream is set up.
git fetch upstream
git merge upstream/master
git push
NOTE: The fork of a repo can be deleted once the pull request has been approved.
see https://help.github.com/articles/using-pull-requests
- Click the "Fork" button online on the project to you want to fork.
- Go to
https://github.com/blue-ice/<cloned-repo-name>/settings
and rename the repo. - We need to grab the entire repository, selecting the branch needed and the local location that should be used:
git clone -b <branch-name> [email protected]:blue-ice/<renamed-repo-name>.git ~/Documents/git-repositories/<renamed-repo-name>
cd <repo-name>
- Add a new upstream:
git remote add upstream https://github.com/<forked-user>/<forked-repo-name>.git
git push -u origin master
- Edit the file.
git add <file-name>
git checkout --theirs README.md
git add README.md
git checkout --ours README.md
git add README.md
-
git clone <into-repo>
-
git clone <from-repo>
-
cd <into-repo>
-
git checkout <into-repo-branch>
-
git remote add temp-remote ../<from-repo>
-
git fetch temp-remote
-
git branch temp-branch temp-remote/<from-repo-clone-branch>
-
git checkout temp-branch
-
mkdir <from-repo>
-
rsync --remove-source-files -av ./ ./<from-repo> --exclude .git
-
git add -A
-
git commit -m "Reorganized files from other repository."
-
git clean -fd
-
git checkout <into-repo-branch>
-
git merge temp-branch
-
git push
-
git branch -D temp-branch
-
git remote rm temp-remote
- If
git branch -a
shows nonexistent branches... - It most likely needs a
git fetch -p
to fetch and prune the repository - If that doesn't work, the bad branch has a local copy and/or a remote copy that both need to be deleted (check out of the branch first):
- Local deletion:
git branch -D <branch-name>
- Remote deletion:
git push origin --delete <branch-name>
- Local deletion:
- The
<master>
(or "default") branch is the basis for user profile updates. See here for information on merging to correct the issue.